android - 请求三星将我的应用列入电池优化白名单 'Put app to sleep'

标签 android samsung-mobile android-doze samsung-knox

我们有一个播客播放器应用程序,它在大多数手机上运行良好,但一些三星用户报告说当屏幕关闭时流媒体停止播放。我们正在使用前台服务和通知来使用 ExoPlayer 进行播放。

经过一些调查后发现,如果您在“设置”->“设备维护”->“电池”中为我们的应用禁用“让应用进入休眠状态”,它会按预期工作。

是否可以为我们的应用程序自动禁用让应用程序进入休眠状态? 我已阅读有关 Samsung Knox API ApplicationPolicy.addPackageToBatteryOptimizationWhiteList() 的信息,但这需要为我们的应用程序请求设备管理员权限,这对用户来说会很可怕。

最佳答案

来自documentation

An app holding the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission can trigger a system dialog to let the user add the app to the whitelist directly, without going to settings. The app fires a ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS Intent to trigger the dialog.

Before asking the user to add your app to the whitelist, make sure the app matches the acceptable use cases for whitelisting.

顺便问一下,所有应用程序的“让应用程序进入休眠状态”不是应该默认关闭吗?至少我的 S8 是这样。

关于android - 请求三星将我的应用列入电池优化白名单 'Put app to sleep',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57511260/

相关文章:

android - 如何在一个应用程序中获得多个图标来启动不同的 Activity ?

java - 无法为 WebView 创建图层,尺寸 640x7040 最大尺寸 8192 颜色类型 4 具有上下文 1

android - 三星sm-t531开发者选项在哪里

android - 打瞌睡模式处理

android - 是否可以跟踪应用何时进入 "Doze on the Go"(又名 Doze Light、Doze Extended 和 Doze 2)?

android - 如何计算与 map 中不同标记的距离,然后选择最少的一个

android - 如何完成销毁的 Activity

android - libgdx:SpriteBatch,Samsung Android 设备上的 fragment 着色器工作不正确

当应用程序处于打瞌睡模式时,由警报管理器触发的 Android 通知不会触发

android - Xamarin Android 安装失败