简体   繁体   中英

Detect unlock screen type on Android

Is there a way to detect how actually user unlock phone? - via PIN or pattern or using swipe gesture I've googled only smth about registering Receiver with this code in onReceive()

KeyguardManager keyguardManager = 
            (KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE);
        if (keyguardManager.isKeyguardSecure())

Since the Settings.Secure.getLong method is deprecated since API level 23, and that it has been replaced by the KeyGuardManager , it doesn't seem possible to retrieve the exact lock type.

As you've found out, using isDeviceSecure() is the closest information you can retrieve.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM