get Is Screen Locked - Android User Interface

Android examples for User Interface:Screen Lock

Description

get Is Screen Locked

Demo Code


//package com.java2s;

import android.content.Context;

import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;

public class Main {
    @SuppressWarnings("deprecation")
    public static boolean getIsScreenLocked(Context context) {
        boolean flag = false;

        try {//from www  .j a  v  a  2  s .c  om
            flag = Settings.Secure.getInt(context.getContentResolver(),
                    Settings.System.LOCK_PATTERN_ENABLED) == 1;
        } catch (SettingNotFoundException e) {
            e.printStackTrace();
        }

        return flag;
    }
}

Related Tutorials