java - Android How to disable pattern lock -
i want disable screen lock. show screen , after dismissing it, want lock screen again, purpose using code.
after oncreate()
powermanager pm = (powermanager) this.getsystemservice(context.power_service); wakelock = pm.newwakelock(powermanager.full_wake_lock | powermanager.acquire_causes_wakeup | powermanager.on_after_release, "info"); keyguardmanager km = (keyguardmanager) this.getsystemservice(context.keyguard_service); kl = km .newkeyguardlock("mykeyguardlock"); kl.disablekeyguard();
and on dismissing screen using, kl.reenablekeyguard() lock screen again.
this working absolutely great if using swipe screen lock, if using pattern lock, code not working. know possible, there apps doing this, far unable find way out.
edit : found code working in nexus, not on galaxy
you create activity start when needed with:
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.getwindow().setflags( windowmanager.layoutparams.flag_keep_screen_on | windowmanager.layoutparams.flag_show_when_locked | windowmanager.layoutparams.flag_turn_screen_on, windowmanager.layoutparams.flag_keep_screen_on | windowmanager.layoutparams.flag_show_when_locked | windowmanager.layoutparams.flag_turn_screen_on); }
wakelocks deprecated , window flags should used.
edit: works normal/transparent theme, doesn't work dialog theme.
Comments
Post a Comment