Android examples for User Interface:Screen Dormant
is Screen On by checking PowerManager
//package com.java2s; import android.content.Context; import android.os.Build; import android.os.PowerManager; public class Main { public static boolean isScreenOn(Context context) { Context appContext = context.getApplicationContext(); PowerManager pm = (PowerManager) appContext .getSystemService(Context.POWER_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { return pm.isInteractive(); } else {/*from w w w . j a v a2 s . c om*/ // noinspection all return pm.isScreenOn(); } } }