开发者

Looking for a way to see if an application is closed

开发者 https://www.devze.com 2023-03-10 08:05 出处:网络
Is there a good way to check if an entire application (not an activity!) is closed by the user? I want to log the time a user spends using the application, so a simple activity onPause() ,onStop() or

Is there a good way to check if an entire application (not an activity!) is closed by the user? I want to log the time a user spends using the application, so a simple activity onPause() ,onStop() or onDestroy() is not sufficient.

There are several ways an application can be closed, either the user pressing the home button, 开发者_运维技巧search button or simply leaving the application. Is there a unified (eg. simple) way to see if any of these things happened?


There are several ways an application can be closed, either the user pressing the home button, search button or simply leaving the application.

Neither of these actually closes the application. The activities will continue to run unless you explicitly call finish() or the system kills them when it runs out of resources.

Why is not sufficient to use onResume() and onPause()?


will overriding finalize() to the App class (that extends Application) help for this job ?

if not , maybe a reference inside this class to another class that has this method?

0

精彩评论

暂无评论...
验证码 换一张
取 消