Example usage for android.view Display STATE_OFF

List of usage examples for android.view Display STATE_OFF

Introduction

In this page you can find the example usage for android.view Display STATE_OFF.

Prototype

int STATE_OFF

To view the source code for android.view Display STATE_OFF.

Click Source Link

Document

Display state: The display is off.

Usage

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;/*  w  w w  . j  a  v a2s.  com*/
            }
        }
        return screenOn;
    } else {
        PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
        //noinspection deprecation
        return pm.isScreenOn();
    }
}