在打盹模式网络访问

编程入门 行业动态 更新时间:2024-10-20 05:26:13
本文介绍了在打盹模式网络访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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);

更多推荐

在打盹模式网络访问

本文发布于:2023-11-27 08:25:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637272.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模式   网络

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!