Hi,

has something changed in the latest OS update (Android 2.2.1, Nexus
One) about disabling keyguards? I have an app that has an alarm
feature and wakes up the phone + disables the keyguard; the keyguard
disabling doesn't happen anymore. Here's what i'm doing:

private final void unlockScreen() {
    final KeyguardManager km = ((KeyguardManager)
getSystemService(Activity.KEYGUARD_SERVICE));
    if (km.inKeyguardRestrictedInputMode()) {
      final KeyguardLock kl = km.newKeyguardLock(KEYGUARD_SERVICE);
      kl.disableKeyguard();
    }
  }

  private final void wakeScreen() {
    final boolean dim = sPref.getBoolean(Config.ALARM_DIM, false);
    final PowerManager.WakeLock wl = ((PowerManager)
getSystemService(Context.POWER_SERVICE))
        .newWakeLock((dim ? PowerManager.SCREEN_DIM_WAKE_LOCK
            : PowerManager.SCREEN_BRIGHT_WAKE_LOCK)
            | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TagToDoWake");
    wl.acquire();
    new Handler().postDelayed(new Runnable() {
      public void run() {
        wl.release();
      }
    }, 20000);

And i'm calling them in this order:
    wakeScreen();
    unlockScreen();

Thanks,
Teo

-- 
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