为什么当应用程序被杀死时 AlarmManager 广播会被取消?
好的,我注册了两个广播接收器。当应用程序关闭时,它们都会在适当的时间触发并执行适当的操作。
如果应用程序被关闭然后被杀死(比如使用 AppKiller),接收者将永远不会收到他们的广播,并且什么也不会发生。
如果父应用程序由于内存不足而被终止,大概也会发生同样的事情,那么我如何确保这些广播被触发/接收。 API 规定,即使应用程序被终止,它也应该启动,其他人有遇到这种情况的经验吗?
如果它有帮助我的清单是:
<!-- 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>
AlarmManager/BroadcastReceivers 中没有发生任何深奥的事情
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 broadcasts 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的推测是错误的。所谓的“任务杀手”正在利用一种特定的 API,该 API 不会在内存不足的情况下使用。 “任务杀手”API 可以摧毁一切,包括预定的警报。
此外,您的父应用程序希望一开始就不在内存中。使用 AlarmManager 的全部目的是让您的“父应用程序”在不执行任何操作时不会占用内存。
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.