Android examples for android.os:Battery
is Battery Optimization Disabled
import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Build; import android.os.PowerManager; import android.provider.Settings; public class Main{ /**/* w w w .ja v a2 s . c o m*/ * Check whether the battery optimization is disabled for the application * * @param context * @return */ @TargetApi(Build.VERSION_CODES.M) // public static boolean isBatteryOptimizationDisabled(Context context) { String packageName = context.getPackageName(); PowerManager pm = (PowerManager) context .getSystemService(Context.POWER_SERVICE); return pm.isIgnoringBatteryOptimizations(packageName); } }