Get the intent to either request ignore battery optimization or open battery optimization settings depend on whether the battery optimization is already disabled for the application - Android Hardware

Android examples for Hardware:Battery

Description

Get the intent to either request ignore battery optimization or open battery optimization settings depend on whether the battery optimization is already disabled for the application

Demo Code


//package com.java2s;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;

import android.os.Build;

import android.provider.Settings;

public class Main {

    @TargetApi(Build.VERSION_CODES.M)//w  ww  .jav a  2  s.  c  om
    //
    public static Intent getBatteryOptimizationIntent(Context context) {
        Intent intent = new Intent();
        intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);

        return intent;
    }
}

Related Tutorials