Search code examples
androidalarmmanagerlow-memory

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


My Receiver will load when device got boot up and start the alarm manager to schedule every 10second to check my other service is still running. Now I wonder will the Alarm Receiver get killed or stop receiving broadcast if memory low. Cos i need constantly check my other service are still available and not get killed by the system. If I the service got destroy or not restart again, the alarm receiver can start the service automatically).


Solution

  • A Broadcast Receiver (in particular, an Alarm Receiver) can be killed by the system in cases of "extreme memory pressure". That is: it will not happen in regular situations, but it could happen.

    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.

    From Android documentation.