Application.onLowMemory() not invloked

前端 未结 1 1437
夕颜
夕颜 2021-01-07 13:44

I\'ve create an Application class of my own.

I try to debug it and the code stops at Application.onCreate() but does not stop at onLowMemory.

To test the sce

相关标签:
1条回答
  • 2021-01-07 13:59

    I don't think that there are any guarantees that this method will ever be called.

    From the docs:

    While the exact point at which this will be called is not defined, generally it will happen around the time all background process have been killed, that is before reaching the point of killing processes hosting service and foreground UI that we would like to avoid killing.

    Since the point at which it is called is not defined, it could choose to never call it.

    In general, Android is free to kill your Application whenever it wants, as long as it is in the background. You should only rely on methods in the lifecycle (like onPause, onStop, onDestroy) that specifically state that they are guaranteed to be called in order to do any necessary cleanup.

    0 讨论(0)
提交回复
热议问题