I'm building a app which wakes and unlock's the phone on a event.
This works fine..
only when leaving the activity (or when a timer runs out..for when there's nobody around) i use reenableKeyguard() to restore the keylock to origenal state...
but then it locks directly....
i would like the normal behavour...so when the user exit's my app..there's no lock yet. but after 30 sec. of no activity phone goes to sleep and sets lock.
how can i do this... thanks.
Below is the code I have used for this:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getWindow().addFlags(
LayoutParams.FLAG_DISMISS_KEYGUARD
| LayoutParams.FLAG_SHOW_WHEN_LOCKED
| LayoutParams.FLAG_TURN_SCREEN_ON
| LayoutParams.FLAG_KEEP_SCREEN_ON
);
KeyguardManager manager = (KeyguardManager) getSystemService
(Context.KEYGUARD_SERVICE);
lock = manager.newKeyguardLock
("hh");
lock.disableKeyguard();
}
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
lock.reenableKeyguard();
}
PLease let me know what are the changes I need to do in above code so it works nicely.