gpt4 book ai didi

android - 打瞌睡模式、电池优化白名单、AlarmManager 频率超过 9 分钟

转载 作者:搜寻专家 更新时间:2023-11-01 09:24:57 24 4
gpt4 key购买 nike

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

传感器周期性休眠,仅在有限的时间窗口内唤醒以进行连接。

我尝试创建 AlarmManager,它使用 setExactAndAllowWhileIdle() 触发前台服务,并且它在超过 9 分钟的时间内按预期工作,

但低于 9 分钟它会进入休眠模式并且不会触发 AlarmManager BroadcastReceiver。

根据文档,我不明白将应用程序添加到电池优化白名单是否会允许 AlarmManager 更频繁地触发 https://developer.android.com/training/monitoring-device-state/doze-standby#support_for_other_use_cases

For example, the whitelisted app’s jobs and syncs are deferred (on API level 23 and below), and its regular AlarmManager alarms do not fire

什么是常规警报? setExactAndAllowWhileIdle() 是常规的吗?

任何澄清将不胜感激

编辑:

我知道 setExactAndAllowWhileIdle() 会在休眠模式下触发事件超过 9 分钟,问题是将应用程序添加到白名单是否会允许它更频繁地触发

最佳答案

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

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

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

它对设置闹钟的频率有限制。

基于documentation :

To reduce abuse, there are restrictions on how frequently these alarms will go off for a particular application. Under normal system operation, it will not dispatch these alarms more than about every minute (at which point every such pending alarm is dispatched); when in low-power idle modes this duration may be significantly longer, such as 15 minutes.

可以引用Doze restrictions其中说:

Standard AlarmManager alarms (including setExact() and setWindow()) are deferred to the next maintenance window.

  • 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

对于白名单:

白名单中可用的应用部分免于打瞌睡和应用待机优化。这并不意味着他们可以完全访问并可以在打瞌睡模式下执行任务。列入白名单的应用程序可以使用网络并在打盹和应用程序待机期间保持部分唤醒锁定。然而,其他限制,如工作不同,标准警报触发仍然强加

注意:您应该 check acceptable usecases用于将应用列入白名单。

Google Play policies prohibit apps from requesting direct exemption from Power Management features in Android 6.0+ (Doze and App Standby) unless the core function of the app is adversely affected.

关于android - 打瞌睡模式、电池优化白名单、AlarmManager 频率超过 9 分钟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51399353/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com