Android.Content.IComponentCallbacks2
Extended Android.Content.IComponentCallbacks interface with a new callback for finer-grained memory management.

See Also: IComponentCallbacks2 Members

Syntax

[Android.Runtime.Register("android/content/ComponentCallbacks2", "", "Android.Content.IComponentCallbacks2Invoker")]
public interface IComponentCallbacks2 : IComponentCallbacks, IDisposable

Remarks

Extended Android.Content.IComponentCallbacks interface with a new callback for finer-grained memory management. This interface is available in all application components (Android.App.Activity, Android.App.Service, Android.Content.ContentProvider, and Android.App.Application).

You should implement ComponentCallbacks2.onTrimMemory(int) to incrementally release memory based on current system constraints. Using this callback to release your resources helps provide a more responsive system overall, but also directly benefits the user experience for your app by allowing the system to keep your process alive longer. That is, if you don't trim your resources based on memory levels defined by this callback, the system is more likely to kill your process while it is cached in the least-recently used (LRU) list, thus requiring your app to restart and restore all state when the user returns to it.

The values provided by ComponentCallbacks2.onTrimMemory(int) do not represent a single linear progression of memory limits, but provide you different types of clues about memory availability:

Note: When the system begins killing processes in the LRU list, although it primarily works bottom-up, it does give some consideration to which processes are consuming more memory and will thus provide more gains in memory if killed. So the less memory you consume while in the LRU list overall, the better your chances are to remain in the list and be able to quickly resume.

More information about the different stages of a process lifecycle (such as what it means to be placed in the background LRU list) is provided in the Processes and Threads document.

[Android Documentation]

Requirements

Namespace: Android.Content
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 14