AndroidMemoryLevelNotifier

Listens for ComponentCallbacks2.onTrimMemory callbacks. When the trim level is ComponentCallbacks2.TRIM_MEMORY_MODERATE or ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW then MemoryLevelCallbacks.onLowMemory is called. When the trim level is ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL or ComponentCallbacks2.TRIM_MEMORY_COMPLETE then MemoryLevelCallbacks.onCriticalMemory is called. When memoryLevelCallbacks is null then Context.unregisterComponentCallbacks is called to avoid leaking this object. Therefore, once the callbacks are no longer needed it is important to set memoryLevelCallbacks to null.

Parameters

context

used to call Context.getApplicationContext and then Context.registerComponentCallbacks to listen to trim memory events.

Constructors

Link copied to clipboard
constructor(context: Context)

Properties

Link copied to clipboard