Hi,
In my application I want to use KeyguardManager to present the unlock
screen at required places. I wrote the following code and tested it on
Google IO phone (Android 1.6) and a Nexus One phone. Although this
works decently on Nexus one, its behavior is odd at times. Sometimes
the unlock screen doesn't appear for consecutive runs. It also has
serious issues with configuration changes. And surprisingly, if I turn
off the screen and turn it back on, the unlock screen disappears! Of
course, this happens only in my program, and not in general in the
phone.

Can someone explain what's wrong with my code? Just FYI, I have tried
various combinations of disableKeyguard() and reenableKeyguard()
without much gain.

public class UnlockActivity extends Activity {
    KeyguardManager mKgm;
    KeyguardLock mKgl;
        
    @Override
    public void onCreate(Bundle savedInstanceState) {
        ...
        mKgm = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
        mKgl = mKgm.newKeyguardLock("me");
   }

    class HandlerCallback implements Handler.Callback {
        public boolean handleMessage(Message msg) {
                mKgl.disableKeyguard();
                mKgm.exitKeyguardSecurely(new OnKeyguardExitResult() {
                                public void onKeyguardExitResult(boolean 
success) {
                                        Log.d("UnlockActivity", "status: " + 
success);
                                        mKgl.reenableKeyguard();
                                }
                        });
                return true;
        }
    }
   ...
}


thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to