OnLowMemory () Android app for API> = 14

a tiny question.

According to Android docs:

Preferably you should implement ComponentCallbacks2.onTrimMemory from ComponentCallbacks2 to gradually unload resources based on different levels of memory requirements. This API is available for API level 14 and above, so you should use this onLowMemory method as a reserve for older versions.

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

thanks!

+6
source share
1 answer

Yes, absolutely. It is not deprecated at any API level. You must use both onTrimMemory() and onLowMemory() to keep the system up and onLowMemory() .

This is described in more detail in the video: Crop and memory sharing (Android Performance Patterns Season 3 ep5) .

+2
source

All Articles