Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

isKeyguardLocked vs isDeviceLocked

I'm currently facing a troublesome bug with some Android Devices. I'm checking up on KeyguardManager to see if I need to disable audio or not (I want the audio be disabled whenever the game is not active or screen is locked etc.)

I've been using isDeviceLocked method to see if the user has access or not.

But now I found a device that continuously reports that `isDeviceLocked' == true.

Android docs says

boolean isDeviceLocked ()

Returns whether the device is currently locked and requires a PIN, pattern or password to unlock.

boolean isKeyguardLocked ()

Return whether the keyguard is currently locked.

What's the difference between isDeviceLocked and isKeyguardLocked, except for that they were added in different SDK versions?

like image 678
Habba Avatar asked Jun 08 '16 13:06

Habba


1 Answers

The isDeviceLocked() method returns true only when the device is locked and requires a PIN, pattern or password to unlock. The isKeyguardLocked() method is similar but it will also return true if the device is locked without any security.

like image 161
paprikanotfound Avatar answered Oct 29 '22 18:10

paprikanotfound