当应用程序被强制关闭AlarmManager不起作用

编程入门 行业动态 更新时间:2024-10-22 10:57:14
本文介绍了当应用程序被强制关闭AlarmManager不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

文档 AlarmManager startes了

Documentation for AlarmManager startes that

注:报警管理的目的是为您希望让自己的应用code运行在特定的时间的情况下,即使你的应用程序当前未运行。对于正常的定时操作(蜱,超时,等等)更容易和更有效地使用处理程序

Note: The Alarm Manager is intended for cases where you want to have your application code run at a specific time, even if your application is not currently running. For normal timing operations (ticks, timeouts, etc) it is easier and much more efficient to use Handler.

不过,一旦我的应用程序被关闭(强制关闭从任务管理器)我的报警器不工作和的onReceive 方法不会被调用广播接收器内。 我瞄准4.x版。

However, once my application is closed (force close from task manager) my alarm does not work and the OnReceive method is never called inside the broadcast receiver. I am targeting 4.x.

这是怎么回事?

推荐答案

什么@Shrikant说是pretty的很好的解决。

What @Shrikant says is pretty much the answer.

的时间越长verison是,它是假定由机器人出了某种错误与应用程序,如果用户不得不手动强制关闭它。因此相关的应用程序的所有活动(BroadcastReceiver的年代,报警等)不会被启动,直到该应用被用户手动运行至少一次。例如,应用程序的启动的BroadcastReceiver不会当设备被关闭,在这种状态下,直到用户运行的应用程序,那么的下一步的设备引导事件将被传递到应用程序的BroadcastReceiver的调用。

The longer verison is that it is assumed by Android that something is amiss with the app if the user had to force close it manually. Therefore all activities (BroadcastReceiver's, alarms, etc) related to the app will not be initiated until the app is run manually by the user at least once. For example, app's boot BroadcastReceiver will not be called when device is turned off and on in this state until the user runs the app, then the next device boot event will be delivered to the app's BroadcastReceiver.

此行​​为被确认为设计由Android框架开发者:groups.google/forum/?fromgroups=#!topic/android-developers/anUoem0qrxU

This behavior is confirmed as by design by Android framework devs: groups.google/forum/?fromgroups=#!topic/android-developers/anUoem0qrxU

*编辑的语法和放大器;添加了一个例子行为

*edited for grammar & added an example behavior

更多推荐

当应用程序被强制关闭AlarmManager不起作用

本文发布于:2023-11-27 04:17:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636561.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   不起作用   AlarmManager

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!