简体   繁体   中英

Android Application onLowMemory() on API >= 14

a tiny question.

According to the Android docs:

Preferably, you should implement ComponentCallbacks2.onTrimMemory from ComponentCallbacks2 to incrementally unload your resources based on various levels of memory demands. That API is available for API level 14 and higher, so you should only use this onLowMemory method as a fallback for older versions

So. Will onLowMemory() be called by higher API's as well?
Clearly, I just want to call it from within onTrimMemory() when the level is TRIM_MEMORY_COMPLETE , but I don't want it to be called twice :)

Thx!

Yes, absolutely. It is not deprecated at any API level. You should be implementing both onTrimMemory() and onLowMemory() for the sake of keeping the system healthy.

These are covered in more detail in the video: Trimming and Sharing Memory (Android Performance Patterns Season 3 ep5) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM