Android - 当应用程序被杀死以回收资源时是否有系统广播意图?
我正在尝试编写一个 BroadcastReceiver,以便在 Android 操作系统终止应用程序以回收资源时收到通知。我尝试过过滤“android.intent.action.PACKAGE_RESTARTED”,但我似乎从未收到该广播,即使我强制关闭应用程序也是如此。
那么,我是否使用了正确的意图操作过滤器?如果不是,那么正确的是什么?或者这根本不可能?
谢谢!
I'm attempting to write a BroadcastReceiver to be notified when the Android OS kills an app in order to reclaim resources. I've tried filtering on "android.intent.action.PACKAGE_RESTARTED" but I never seem to receive that broadcast, even when I force close an application.
So, am I using the correct intent action filter? If not, what is the proper one? Or is this simply not possible?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
史蒂夫,
不幸的是,如果有这样的操作,则没有记录。最接近的方法是在“前台”运行服务并检查特定应用程序是否正在运行。毕竟,您没有理由不能创建这样的意图。
模糊逻辑
Steve,
Unfortunately, if there is such an Action, it is not documented. The closest that you could get to is to run a service in the "foreground" and check if a particular application is running. There is no reason, after all, that you couldn't create such an Intent.
FuzzicalLogic