I am making an app that enables\disables a keyguard but it works only for the first time this activity is called and after that its remains in the state I set for the first time.
static boolean k=true;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
if(k)
{
Log.d("unlock", "done");
KeyguardManager myKeyGuard1 = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
KeyguardLock myLock1 = myKeyGuard1.newKeyguardLock(null);
myLock1.disableKeyguard();
k=false;
finish();
}
else{
Log.d("lock", "done");
KeyguardManager myKeyGuard = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
KeyguardLock myLock = myKeyGuard.newKeyguardLock(null);
myLock.reenableKeyguard();
k=true;
finish();
}
setContentView(R.layout.home);
}