List of usage examples for android.os PowerManager isDeviceIdleMode
public boolean isDeviceIdleMode()
From source file:Main.java
@TargetApi(Build.VERSION_CODES.M) public static boolean isDeviceIdleMode(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { return false; }//from ww w. j av a 2 s .co m PowerManager pm = (PowerManager) context.getSystemService(Service.POWER_SERVICE); return pm.isDeviceIdleMode(); }
From source file:com.mendhak.gpslogger.common.Systems.java
/** * Returns true if the device is in Doze/Idle mode. Should be called before checking the network connection because * the ConnectionManager may report the device is connected when it isn't during Idle mode. * https://github.com/yigit/android-priority-jobqueue/blob/master/jobqueue/src/main/java/com/path/android/jobqueue/network/NetworkUtilImpl.java#L60 *///from www . j a v a2 s . c o m @TargetApi(23) public static boolean isDozing(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); return powerManager.isDeviceIdleMode() && !powerManager.isIgnoringBatteryOptimizations(context.getPackageName()); } else { return false; } }