List of usage examples for android.view Display getState
public int getState()
From source file:com.mathi_amorim.emmanuel.metrictime.UpdateTimeService.java
public boolean isScreenOn() { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { DisplayManager dm = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); boolean screenOn = false; for (Display display : dm.getDisplays()) { if (display.getState() != Display.STATE_OFF) { screenOn = true;//from w w w . j a v a 2 s . c om } } return screenOn; } else { PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); //noinspection deprecation return pm.isScreenOn(); } }