get Battery Optimization Intent - Android android.os

Android examples for android.os:Battery

Description

get Battery Optimization Intent

Demo Code

import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.provider.Settings;

public class Main{

    /**//from www.jav a  2 s.  c o  m
     * 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
     *
     * @param context
     * @return
     */
    @TargetApi(Build.VERSION_CODES.M)
    //
    public static Intent getBatteryOptimizationIntent(Context context) {
        Intent intent = new Intent();
        intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);

        return intent;
    }

}

Related Tutorials