Android: 如果应用程序被系统杀死,警报管理器是否被杀死

Android: Does Alarm Manager get killed if the application get kill by system

我的接收器将在设备启动时加载并启动警报管理器以每 10 秒安排一次以检查我的其他服务是否仍然 运行。现在我想知道如果内存不足,警报接收器是否会被杀死或停止接收广播。 因为我需要经常检查我的其他服务是否仍然可用并且不会被系统杀死。如果我的服务被销毁或没有重新启动,报警接收器可以自动启动服务)。

在 "extreme memory pressure" 的情况下,广播接收器(特别是警报接收器)可能会被系统杀死。也就是说:它不会在常规情况下发生,但可能发生。

Process Lifecycle

A process that is currently executing a BroadcastReceiver (that is, currently running the code in its onReceive(Context, Intent) method) is considered to be a foreground process and will be kept running by the system except under cases of extreme memory pressure.

来自 Android documentation.