PoweSavingMode 与 App 优化
PoweSavingMode Vs App optimization
我需要知道整个系统或我的应用程序是否有任何节电政策。
我发现您可以通过调用来检查省电模式是否已激活:
PowerManager oPowerManager = (PowerManager) oContext.getSystemService(Context.POWER_SERVICE);
boolean bActivated = oPowerManager.isPowerSaveMode();
但是,我如何知道我的应用程序是否在应用程序优化列表中?
在 PowerManager
上致电 isIgnoringBatteryOptimizations()
。引用 the documentation:
Return whether the given application package name is on the device's power whitelist. Apps can be placed on the whitelist through the settings UI invoked by ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS.
我需要知道整个系统或我的应用程序是否有任何节电政策。
我发现您可以通过调用来检查省电模式是否已激活:
PowerManager oPowerManager = (PowerManager) oContext.getSystemService(Context.POWER_SERVICE);
boolean bActivated = oPowerManager.isPowerSaveMode();
但是,我如何知道我的应用程序是否在应用程序优化列表中?
在 PowerManager
上致电 isIgnoringBatteryOptimizations()
。引用 the documentation:
Return whether the given application package name is on the device's power whitelist. Apps can be placed on the whitelist through the settings UI invoked by ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS.