I am using Android 6 with Cyanogenmod and when I am starting the following intent, then nothing happens!
if(Build.VERSION.SDK_INT >= Constants.IGNORE_BATTERY_OPTIMIZATIONS_MIN_BUILD) {
String packageName = getPackageName();
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
if (!pm.isIgnoringBatteryOptimizations(packageName)) {
Intent intent = new Intent(android.provider.Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).setData(Uri.parse("package:" + packageName));
try {
startActivity(intent);
...
Should the dialog for the Battery optimisation come up? If so, what am I doing wrong?
You need to have this line in your manifest:
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With