Android examples for android.os:PowerManager
get Power Save Status
import android.app.Application; import android.content.Context; import android.os.Build; import android.os.PowerManager; public class Main { public static boolean getPowerSaveStatus() { if (Build.VERSION.SDK_INT >= 21) { try {//from w w w . j a v a 2 s . c o m Context context = getApplicationUsingReflection() .getApplicationContext(); PowerManager pm = (PowerManager) context .getSystemService(Context.POWER_SERVICE); return pm.isPowerSaveMode(); } catch (Exception e) { System.out.println(e); } } return false; } public static Application getApplicationUsingReflection() throws Exception { return (Application) Class.forName("android.app.ActivityThread") .getMethod("currentApplication").invoke(null, (Object[]) null); } }