android - 如何从打瞌睡模式中选择退出应用程序?

标签 android android-6.0-marshmallow

如何让我的应用程序退出 android M DOZE 模式? 是否有一种标准方法可以在运行时有选择地从 DOZE 和自动待机中包含和排除应用程序?

最佳答案

How to opt-out my app from android M DOZE mode ?

你不能通过任何已知的机制。

Is there a standard way to include and exclude apps from DOZE and auto standby selectively at run time ?

理论上,用户可以在“设置”中切换“忽略优化”选项,将应用置于不应进入应用待机模式的应用白名单中。这不会影响打瞌睡模式。

引用 somebody who I believe is Dianne Hackborn :

While the device is dozing, syncs and jobs are turned off globally, putting an app on the whitelist does not change the behavior for them. This is the intended behavior, as is the lack of free use of the alarm manager. (One of the key aspects of all of these is that they are ways to cause the device to wake up, and anything that causes it to wake up will have a significant impact on battery life in the durations we want to last while dozing, so it is simply not allowed.)

While dozing, the AndAllowWhileIdle APIs allow you to wake up the device at most once every 15 minutes; when not dozing this is raise to once every minute. When the device is in idle maintenance mode, all of the doze restrictions are removed (so AllowWhileIdle can happen once a minute).

请注意,“闲置维护模式”目前未记录在案。我的猜测是,这是指闲置但正在充电的设备。

关于android - 如何从打瞌睡模式中选择退出应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31720246/

相关文章:

android - 如何从我的应用程序存储数据

android - 如何将我自己的库发布到 TFS?

android - 使用 LocationManager 检查权限的服务

android - gmaps 的 MarshMallow 权限

Android GoogleMap 跟随我的位置

java - 如何在 Android 上编辑谷歌日历事件?

Android Marshmallow - 为什么不询问用户就授予危险权限

android - Espresso - 单击对话框的按钮

android - 如何从 Android 6 自动备份中排除整个目录?

Android 模拟器不安装我的应用程序