check whether lock was enabled or not

Starting with Android 6.0 Marshmallow (SDK 23), there is a new method to accomplish this task. Check this

http://developer.android.com/reference/android/app/KeyguardManager.html#isDeviceSecure()

Usage:

public static boolean isDeviceSecure(Context context)
{        
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
    {
        KeyguardManager manager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
        return manager.isDeviceSecure();
    }
// reflection code from the other answers here
...
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)