isKeyguardLocked vs isDeviceLocked
Asked Answered
O

1

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?

Obovoid answered 8/6, 2016 at 13:43 Comment(1)
Maybe it's a duplicate answer. Reference this link What's the difference between isDeviceLocked and isKeyguardSecure in android's KeyguardManager?Protoxide
A
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.

Agnew answered 29/1, 2019 at 12:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.