For several days i am trying to find a solution to this question, there are a lot of posts already on google and on this website, and from all of this is seems that it is impossible to override home button.
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_HOME) {
return true;
}
return super.onKeyDown(keyCode, event);
}
For certain this it won t work.
不管怎样,在什么地方可以看一看工作,让你在压力下引发某种事情,似乎有一部分工作要做。
protected void onUserLeaveHint() {
super.onUserLeaveHint();
Log.i("LOG", "onUserLeaveHint");
}
但是,我想要做的是可再生的凯保拉(我知道,为了让锁的屏幕首先能够脱掉)偏离这种方法,但出于某种原因,它赢得了拖网。 因此,这是我的法典。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_lock);
}
public void onStart() {
super.onStart();
Globals.km = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
Globals.kl = Globals.km.newKeyguardLock("My_App");
Globals.kl.disableKeyguard();
Log.i("LOG", "OnStart");
}
public void onResume() {
super.onResume();
Log.i("LOG", "OnResume");
}
protected void onUserLeaveHint() {
super.onUserLeaveHint();
Log.i("LOG", "onUserLeaveHint");
Globals.kl.reenableKeyguard();
}
public void onPause() {
super.onPause();
Log.i("LOG", "OnPause");
}
protected void onStop() {
super.onStop();
Log.i("LOG", "OnStop");
}
Reenable works only when the activity start, so if i put it inside of onPause() the lock screen will appear. But when i press home it doesn t work.
谁能告诉我,我究竟是做错了吗? Thanx。