Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
244 views
in Technique[技术] by (71.8m points)

android - problem with KeyGuardManager

I am trying to use the KeyGuardManager to unlock the phone easily. so far no problems the phone is unlocked and all is good. However when this code is executed later I notice my phone is behaving weirdly. until a I see the following message in the Logcat file :

WindowManagerService.mKeyguardTokenWatcher: cleaning up leaked reference

meaning as far as I can tell the reference to the key-guard was leaked. I have no idea why this would happen especially as I cannot see a method which seems to safely dispose of the keyguard lock.

The code that aquaired the lock looks like this:

// use KeyGuardManager to automaticly unlock the device
    KeyguardManager kgm = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
    KeyguardLock kgl = kgm.newKeyguardLock("BusSnooze");

    if (kgm.inKeyguardRestrictedInputMode())
        kgl.disableKeyguard();

Anyone know why this is happening? thanks, Jason

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I soulved this by using:

kgm.exitKeyguardSafely()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...