编程语言
首页 > 编程语言> > android – 如何知道我的应用程序何时被杀?

android – 如何知道我的应用程序何时被杀?

作者:互联网

我需要知道用户何时杀死我的应用程序(强制停止).我一直在阅读android生命周期,它具有onStop()和onDestroy()函数,这些函数与用户在我的应用程序上结束的每个活动相关,但不是在用户强制停止或杀死我的应用程序时.

有没有办法知道用户何时杀死应用程序?

解决方法:

没有办法确定进程何时被杀死.
How to detect if android app is force stopped or uninstalled?

When a user or the system force stops your application, the entire
process is simply killed. There is no callback made to inform you that
this has happened.

When the user uninstalls the app, at first the process is killed, then
your apk file and data directory are deleted, along with the records
in Package Manager that tell other apps which intent filters you’ve
registered for.

标签:android,android-lifecycle
来源: https://codeday.me/bug/20190916/1806891.html