AbilityPackagepublic interface ElementsCallback
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
onConfigurationUpdated(Configuration configuration) |
Called when the system configuration of the device changes.
|
void |
onMemoryLevel(int level) |
Called when the system has determined to trim the memory, for example, when the ability is running in the
background and there is no enough memory for running as many background processes as possible.
|
void onMemoryLevel(int level)
level - Indicates the memory trim level, which shows the current memory usage status. The values and their
respective meanings are as follows:
5: The application is running properly and will not be killed, but the device is
running slightly low on memory. The system may start to kill processes based on the Least
Recently Used (LRU) list.
10: The application is running properly and will not be killed, but the device is
running extremely low on memory. Your application should release some unnecessary resources
to improve system performance, which accordingly improves the application performance.
15: The application is running properly, but the system has killed most of the
cached processes based on the LRU list. In this case, your application should release as
many unnecessary resources as possible. Otherwise, the system may continue to kill all the
cached processes and start to kill some processes that should be kept running, for example,
services running in the background.
20: The application UI is hidden, for example, because the user touched the Home
key on the device. Your application should releases resources allocated for UI display to
free up memory.
40: The device is running low on memory and your application is around the top of
the LRU list. The system is not likely to kill your application. To keep your application
processes in the cache for a longer time, your application should increase available system
memory by releasing some resources that can be easily restored. In this way, your
application is able to smoothly return to the foreground, instead of being restarted.
60: The device is running extremely low on memory and your application is around
the middle of the LRU list. Your application may be killed later if no more memory is
freed up.
80: The device is running extremely low on memory and your application is at the
end of the LRU list. The system is most likely to kill your application first. In this case,
your application should release all resources that can be released.
void onConfigurationUpdated(Configuration configuration)
This callback method is used only if the configurationChange field has been configured in the
config.json file for the ability currently running in the foreground.
Otherwise, the system restarts the ability instead of calling this callback method.
configuration - Indicates the new Configuration object.