在打盹模式网络访问 [英] Network access in doze mode

查看:231
本文介绍了在打盹模式网络访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用网络访问时打盹被激活?如果我的应用程序忽略了电池优化不进去待机状态,但它的影响打盹呢。我缺少什么?

Is it possible to use network access when doze is active? If my app is ignoring battery optimization doesn't go in standby but it's affected by doze anyway. Am I missing anything?

推荐答案

网络访问被禁止打盹模式下,不管你的应用程序忽略了电池的优化。只有这样,才能唤醒您的设备从打盹模式,并获得网络访问是通过发送一个高优先级的谷歌云信息给你的应用程序。

Network access is disabled in doze mode, regardless if your application is ignoring battery optimizations. The only way to wake-up your device from doze mode and to get network access is by sending a high priority Google Cloud Message to your application.

编辑:它可以让​​Android的忽略你的应用程序,它可以有效地禁用应用程序打盹模式电池优化。然而,这需要使用该方法的 setExactAndAllowWhileIdle 的(最大一个唤醒每15分钟)和用户的交互,其可以这样来完成:

it is possible to let Android ignore battery optimization for your application, which effectively disables doze mode for your application. However, this requires using the method setExactAndAllowWhileIdle (maximum one wakeup each 15 minutes) and user interaction, which can be done like this:

Intent intent = new Intent();
String packageName = context.getPackageName();
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (pm.isIgnoringBatteryOptimizations(packageName))
    intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
else {
    intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
    intent.setData(Uri.parse("package:" + packageName));
}
context.startActivity(intent);

这篇关于在打盹模式网络访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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