如何知道我的应用程序何时被杀死? [英] How to know when my app has been killed?

查看:56
本文介绍了如何知道我的应用程序何时被杀死?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to know when the user kills my app (Force stop). I've been reading the android lifecycle, which has the onStop() and onDestroy() functions, these are related to each activity the user ends on my app, but not when the user forces stop or kills my app.

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

Is there any way to know when the user kills the app?

推荐答案

无法确定进程何时终止.来自 如何检测 android 应用程序是否被强制停止或已卸载?

there's no way to determine when a process is killed. From 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.

当用户卸载应用程序时,首先进程被杀死,然后您的 apk 文件和数据目录以及记录都将被删除在包管理器中告诉其他应用您使用了哪些意图过滤器注册了.

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.

这篇关于如何知道我的应用程序何时被杀死?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆