API 19及更高版本中AlarmManager setRepeating的替代方法? [英] Alternatives for AlarmManager setRepeating in API 19 and above?

查看:252
本文介绍了API 19及更高版本中AlarmManager setRepeating的替代方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序要求重复警报的计时非常准确。从API 19开始,AlarmManager setRepeating现在不精确以节省电池(保存树木和所有树木)。

My app requires very accurate timing of a repeating alarm. Since API 19 the AlarmManager setRepeating is now inexact to save battery ( Save the trees and all ).

是否有任何变通办法来使API 19的setExact方法在循环中工作?

Is there any workaround to get API 19's setExact method to work on a loop?


注意:从API 19开始,所有重复的警报都是不精确的。如果您的应用程序需要精确的交付时间,则它必须使用一次性精确警报,并如上所述每次重新安排。 targetSdkVersion早于API 19的旧版应用程序将继续将其所有警报(包括重复警报)视为完全相同。

Note: as of API 19, all repeating alarms are inexact. If your application needs precise delivery times then it must use one-time exact alarms, rescheduling each time as described above. Legacy applications whose targetSdkVersion is earlier than API 19 will continue to have all of their alarms, including repeating alarms, treated as exact.


推荐答案


是否有任何变通办法来使API 19的setExact方法在循环中工作?

Is there any workaround to get API 19's setExact method to work on a loop?

好的。让您的 BroadcastReceiver 或从警报中获得控制权的任何东西,调用 setExact()安排下一次重复除了进行现有工作外。

Sure. Have your BroadcastReceiver, or whatever is getting control from the alarm, call setExact() to schedule the next recurrence, in addition to doing its existing work.

请记住,该 Android M中后台处理的更改可能会给您带来困难。

Bear in mind, though, that the changes to background processing in Android M may cause you difficulty.

这篇关于API 19及更高版本中AlarmManager setRepeating的替代方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆