public interface

ComponentCallbacks2

implements ComponentCallbacks
android.content.ComponentCallbacks2
Known Indirect Subclasses

Class Overview

Extended ComponentCallbacks interface with a new callback for finer-grained memory management.

Summary

Constants
int TRIM_MEMORY_BACKGROUND Level for onTrimMemory(int): the process has gone on to the LRU list.
int TRIM_MEMORY_COMPLETE Level for onTrimMemory(int): the process is nearing the end of the background LRU list, and if more memory isn't found soon it will be killed.
int TRIM_MEMORY_MODERATE Level for onTrimMemory(int): the process is around the middle of the background LRU list; freeing memory can help the system keep other processes running later in the list for better overall performance.
int TRIM_MEMORY_UI_HIDDEN Level for onTrimMemory(int): the process had been showing a user interface, and is no longer doing so.
Public Methods
abstract void onTrimMemory(int level)
Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process.
[Expand]
Inherited Methods
From interface android.content.ComponentCallbacks

Constants

public static final int TRIM_MEMORY_BACKGROUND

Since: API Level 14

Level for onTrimMemory(int): the process has gone on to the LRU list. This is a good opportunity to clean up resources that can efficiently and quickly be re-built if the user returns to the app.

Constant Value: 40 (0x00000028)

public static final int TRIM_MEMORY_COMPLETE

Since: API Level 14

Level for onTrimMemory(int): the process is nearing the end of the background LRU list, and if more memory isn't found soon it will be killed.

Constant Value: 80 (0x00000050)

public static final int TRIM_MEMORY_MODERATE

Since: API Level 14

Level for onTrimMemory(int): the process is around the middle of the background LRU list; freeing memory can help the system keep other processes running later in the list for better overall performance.

Constant Value: 60 (0x0000003c)

public static final int TRIM_MEMORY_UI_HIDDEN

Since: API Level 14

Level for onTrimMemory(int): the process had been showing a user interface, and is no longer doing so. Large allocations with the UI should be released at this point to allow memory to be better managed.

Constant Value: 20 (0x00000014)

Public Methods

public abstract void onTrimMemory (int level)

Since: API Level 14

Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process. This will happen for example when it goes in the background and there is not enough memory to keep as many background processes running as desired.

Parameters
level The context of the trim, giving a hint of the amount of trimming the application may like to perform. May be TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_BACKGROUND, or TRIM_MEMORY_UI_HIDDEN.