is Screen Turned On - Android User Interface

Android examples for User Interface:Screen Dormant

Description

is Screen Turned On

Demo Code


//package com.java2s;
import android.content.Context;

import android.os.Build;
import android.os.PowerManager;

public class Main {
    public static boolean isScreenTurnedOn(Context context) {
        PowerManager powerManager = (PowerManager) context
                .getSystemService(Context.POWER_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH)
            return powerManager.isInteractive();
        //noinspection deprecation
        return powerManager.isScreenOn();
    }//from   w w  w  .j a  va2s .co  m
}

Related Tutorials