Why do AlarmManager broadcasts get cancelled when app gets killed?
Ok so I have two BroadcastReceiver registered. When the app is closed they both fire at the appropriate times and do the appropriate things.
If the app is closed then killed (say with an AppKiller), the receivers never receive their broadcasts, and nothing happens.
Presumably the same thing happens if the parent app is killed due to low memory, so how do I ensure those broadc开发者_如何学Pythonasts are fired/received. The API states that even if the app is killed it should fire, does anyone else have experience with this situation?
If it helps my manifest is:
<!-- receivers for AlarmManager -->
<receiver
android:exported="true"
android:label="Shift roster updating calendar."
android:name="com.skooter.shiftroster.backend.service.UpdateCalendar"
>
</receiver>
<receiver
android:exported="true"
android:label="Shift roster checking alarm."
android:name="com.skooter.shiftroster.backend.service.SetWakeup"
>
</receiver>
and nothing esoteric is going on in the AlarmManager/BroadcastReceivers
Presumably the same thing happens if the parent app is killed due to low memory
You presume incorrectly. So-called "task killers" are exploiting a particular API, one that is not used in low-memory conditions. The "task killer" API nukes everything, including scheduled alarms.
Moreover, your parent app hopefully isn't in memory in the first place. The whole point of using AlarmManager
is so your "parent app" is not around taking up memory when it is not doing anything.
精彩评论