我们有一个播客播放器应用程序,它在大多数手机上运行良好,但一些三星用户报告说当屏幕关闭时流媒体停止播放。我们正在使用前台服务和通知来使用 ExoPlayer 进行播放。
经过一些调查后发现,如果您在“设置”->“设备维护”->“电池”中为我们的应用禁用“让应用进入休眠状态”,它会按预期工作。
是否可以为我们的应用程序自动禁用让应用程序进入休眠状态?
我已阅读有关 Samsung Knox API ApplicationPolicy.addPackageToBatteryOptimizationWhiteList()
的信息,但这需要为我们的应用程序请求设备管理员权限,这对用户来说会很可怕。
最佳答案
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/