简体   繁体   English

Android - 当应用程序被杀死以回收资源时是否存在系统广播意图?

[英]Android - Is there a system broadcast intent when an app is killed to reclaim resources?

I'm attempting to write a BroadcastReceiver to be notified when the Android OS kills an app in order to reclaim resources. 我正在尝试编写一个BroadcastReceiver,以便在Android操作系统杀死应用程序时收到通知,以便回收资源。 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. 我已经尝试过滤“android.intent.action.PACKAGE_RESTARTED”,但我似乎从未接收过该广播,即使我强行关闭一个应用程序。

So, am I using the correct intent action filter? 那么,我使用正确的意图动作过滤器吗? If not, what is the proper one? 如果没有,那么适当的是什么? Or is this simply not possible? 或者这根本不可能?

Thanks! 谢谢!

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 FuzzicalLogic

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当应用程序被杀时,Android广播接收器无法正常工作 - Android Broadcast Receiver not working when the app is killed Android-当应用被终止时,从下载管理器接收广播 - Android - Receiving broadcast from Download Manager when the app is killed 当应用程序在 android 版本 9 中被杀死时收听呼叫广播接收器 - listen to call broadcast receiver when app gets killed in android version 9 当应用程序被杀死时使广播接收器活着 - Make Broadcast Receiver Alive when app is killed 当应用程序被杀死时,互联网广播接收器不工作 - Internet broadcast receiver is not working when app is killed Android App在意图发布时被杀死 - Android App Getting Killed on Intent Launch 当应用程序被杀并且处于优化电池模式时,不会收到FCM消息 OnePlus 5t | OnePlus 6 | 错误广播意图回调:result = CANCELLED - Not receiving FCM messages when app is killed and in Optimised battery mode| OnePlus 5t |OnePlus 6 | Error broadcast intent callback: result=CANCELLED 在Android上杀死应用时收到系统托盘通知 - Receive system tray notification when app killed on Android 当应用程序被系统杀死/重新启动时,Android 服务崩溃 - Android service crashes when app killed/restarted by the system 我的应用程序在后台运行时被 android 系统杀死 - my app killed by android system when it running in background
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM