12

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?

Habba
  • 1,179
  • 2
  • 13
  • 32
  • Maybe it's a duplicate answer. Reference this link [What's the difference between isDeviceLocked and isKeyguardSecure in android's KeyguardManager?](https://stackoverflow.com/a/30053876/8063624) – SJ.Je Apr 24 '18 at 06:55

1 Answers1

9

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.

paprikanotfound
  • 343
  • 3
  • 8