How to detected if application is closed

穿精又带淫゛_ 提交于 2019-11-29 08:40:59
Ruchir Baronia

I had the exact same question , and I was stuck on it for days. Luckily, on day 3, I found a solution that works.

public void onTrimMemory(final int level) {
    if (level == ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
        //SCREEN IS NOT SHOWING
}

This onTrimMemory method is extremely useful. It is supposed to be used to optimize your app in memory, but we can use it to our advantage like this also!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!