禁用或检测应用特定的省电模式 [英] Disabling or detecting the app specific power saving mode

查看:121
本文介绍了禁用或检测应用特定的省电模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

三星设备(至少其中一些设备)将所有已安装的应用程序添加到应用程序省电模式"列表中,这会影响后台服务侦听该应用程序的一些关键信息.

Samsung devices (well, at least some of them) add all installed apps to an "App Power Saving Mode" list which affects the background services listening to some crucial info for the app.

某些应用程序以某种方式在安装后禁用此模式,而无需执行任何其他步骤.对在三星上以编程方式禁用应用程序节能模式的评论线程建议诸如Facebook和WhatsApp之类的应用可能已列入操作系统白名单,但我发现这样做的应用并不那么受欢迎.知道如何实现吗?

Some apps, somehow, disable this mode after installation without any extra steps. Comments on Programmatically disable app power saving mode on Samsung thread suggest that apps like Facebook and WhatsApp might be in the OS whitelist but I've seen apps that are not as popular doing the same. Any idea how to achieve this?

我尝试使用 ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS 意图,但没有成功. PowerManager#isIgnoringBatteryOptimizations 开始返回 true ,但是没有为该应用禁用应用省电模式"或电池节省设置"中的内容.

I've tried using ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS intent but no success. PowerManager#isIgnoringBatteryOptimizations starts returning true but neither App Power Saving Mode nor the thing in Battery Saver Settings is disabled for the app.

如果您认为唯一的方法是与三星联系以将该应用列入白名单,那么最佳的位置是哪里?

If you think the only way is to contact Samsung to whitelist the app, where's the best place to do so?

此外,如果无法以编程方式禁用应用程序省电模式",是否有办法检测是否已为该应用程序启用了该功能,以便我可以打开该应用程序并要求用户将其禁用?

Also, if there's no way to disable App Power Saving Mode programmatically, is there a way to detect if it's enabled for the app so that I can open the app and ask the user to disable it?

推荐答案

您好,有两种省电模式:

Hi there are two power save modes:

  • 常规的Android打ze模式

  • the regular android Doze mode,

和自定义的省电模式".

and the custom "Power save mode.

对于打ze模式,动作:

For doze mode the action:

Intent intent = new Intent();intent.setAction((Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);intent.setData(Uri.parse("package:" + packageName))

并开始意图.

但是对于自定义节能模式(尤其是华为等),您必须根据供应商启动自定义节能模式.列表在这里: https://stackoverflow.com/a/48641229/4606542

But for custom power save modes (especially Huawei and some others) you have to start custom power save modes intents based on vendor. The list is here: https://stackoverflow.com/a/48641229/4606542

这篇关于禁用或检测应用特定的省电模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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