如何使我的Android应用程序显示在“超省电"模式下 [英] How do I make my android app appear in Ultra Power Saving Mode

查看:76
本文介绍了如何使我的Android应用程序显示在“超省电"模式下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

某些三星设备具有超省电模式",可以关闭wifi,关闭屏幕灰度并限制某些基本应用的使用.

Some samsung devices have an Ultra Power Saving Mode which turns off wifi, turns the screen grayscale and limits usage to a few basic apps.

它确实允许您添加一些可以使用的应用程序.这些应用程序包括Facebook和WhatsApp.如何使我的应用程序出现在此列表中?我必须对应用程序进行哪些更改才能使其出现在此列表中?还是此列表基于三星维护的白名单?

It however does allow you to add some apps which can then be used. These apps include Facebook and WhatsApp. How do I make my app appear in this list? What changes do I have to make to the app so that it may appear on this list? Or is this list based on a white list maintained by Samsung?

推荐答案

使用权限

It may be possible using the permission REQUEST_IGNORE_BATTERY_OPTIMIZATIONS. This permission does not require explicit user permission. So will be granted. Although this will not prevent a user manually stopping the application.

来自文档:

这是普通权限:请求它的应用将始终是授予了权限,而无需用户批准或查看它.

This is a normal permission: an app requesting it will always be granted the permission, without the user needing to approve or see it.

ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS 会将应用程序列入设备的白名单.

ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS will put the app onto the device's whitelist.

isIgnoringBatteryOptimizations 会让您知道该应用是否已列入白名单.

isIgnoringBatteryOptimizations will let you know if the app is whitelisted.

来自文档的一些注释:

some notes from the docs:

注意:大多数应用程序不应使用此功能;有很多设施平台提供的应用程序可以在各种省电模式.这仅适用于需要深入控制自己的执行,但要付出潜在的代价用户的电池寿命.请注意,这些应用程序可以很好地运行向用户展示高功率消费者的风险设备.

Note: most applications should not use this; there are many facilities provided by the platform for applications to operate correctly in the various power saving modes. This is only for unusual applications that need to deeply control their own execution, at the potential expense of the user's battery life. Note that these applications greatly run the risk of showing to the user as high power consumers on their device.

输入:Intent的数据URI必须指定应用程序包名称与包装"方案一起显示.那是"package:com.my.app".

Input: The Intent's data URI must specify the application package name to be shown, with the "package" scheme. That is "package:com.my.app".

我不建议您滥用此内容.

It's not something I'd recommend abusing.

有一个可接受的用例的列表列入白名单.

通常,除非Doze或App,否则您的应用不应列入白名单待机中断应用程序的核心功能或有技术您的应用无法使用FCM高优先级消息的原因.

In general, your app should not be on the whitelist unless Doze or App Standby break the core function of the app or there is a technical reason why your app cannot use FCM high-priority messages.

感谢 adsamcik ,以获取最新的链接.

Thanks to adsamcik for this latest link.

这篇关于如何使我的Android应用程序显示在“超省电"模式下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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