本文介绍了打ze模式,电池优化白名单,AlarmManager的频率超过9分钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个与BT设备连接的应用,以收集健康数据(即:体温)。

I'm creating an app to connect with BT device to collect heath data (i.e.: body temperature).

传感器会定期睡眠,仅在有限的时间范围内唤醒。

The sensor sleeps for periodic time and wakes up only for limited window of time to connect.

ve试图创建AlarmManager来使用 setExactAndAllowWhileIdle()触发前景服务,并且它在高于9分钟的时间段内按预期工作,

I've tried to create AlarmManager which fires Foreground Service with setExactAndAllowWhileIdle() and it is working as expected for periods higher than 9 minutes,

但在9分钟以下,它将进入打ze模式,并且不会触发AlarmManager BroadcastReceiver。

but below 9 minutes it goes to doze mode and do not fire AlarmManager BroadcastReceiver.

从文档中,我不了解将应用添加到电池优化白名单是否允许AlarmManager触发更多攻击

From documentation I do not understand if adding app to battery optimalization whitelist will allow AlarmManager to trigger more offenhttps://developer.android.com/training/monitoring-device-state/doze-standby#support_for_other_use_cases

常规警报是什么? setExactAndAllowWhileIdle()是否正常?

What are the regular alarms? is setExactAndAllowWhileIdle() regular?

任何澄清将不胜感激

编辑:

我了解到 setExactAndAllowWhileIdle()会在打ze模式下触发事件超过9分钟,问题是将应用添加到白名单是否会使它触发次数更多

I understand that setExactAndAllowWhileIdle() will trigger event in doze mode for periods longer than 9 minutes, question is does adding app to whitelist will allow it to trigger more often

推荐答案

否。 setExactAndAllowWhileIdle()不规则。常规警报可以是通过setExact()和setWindow()设置的AlarmManager警报。

No. setExactAndAllowWhileIdle() is not regular. Regular alarm could be AlarmManager alarms set though setExact() and setWindow().

它对设置警报的频率有限制。

It has restrictions on how frequently you can set alarm.

基于:

您可以参考表示:


  • 如果您需要设置在打ze睡时触发的警报,请使用setAndAllowWhileIdle()或setExactAndAllowWhileIdle()。

  • 使用 setAlarmClock()设置的警报继续正常触发-在这些警报触发之前不久,系统退出Doze。

  • If you need to set alarms that fire while in Doze, use setAndAllowWhileIdle() or setExactAndAllowWhileIdle().
  • Alarms set with setAlarmClock() continue to fire normally — the system exits Doze shortly before those alarms fire

对于白名单:

白名单中可用的应用部分不受Doze和App Standby优化。这并不意味着他们在打ze睡模式下拥有完全访问权限并可以执行任务。被列入白名单的应用程序可以在Doze和App Standby期间使用网络并持有部分唤醒锁。但是,仍会施加其他限制,例如作业不同,标准警报触发

Apps available in whitelist are partially exempt from Doze and App Standby optimizations. This doesn't mean they have full access to and could perform tasks during doze mode. An app that is whitelisted can use the network and hold partial wake locks during Doze and App Standby. However, other restrictions like jobs being differed, standard alarm trigger are still imposed

注意:您应以将应用列入白名单。

Note: You should check acceptable usecases for whitelisting an app.

这篇关于打ze模式,电池优化白名单,AlarmManager的频率超过9分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-14 20:30