问题
On Android 4.4 I develop a lockscreen app, but in lockscreen activity I can't block home button. Can anyone solve it?
回答1:
Override the onKeyDown function of the activity and then catch the event for the home button.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_HOME)) {
Toast.makeText(this, "You pressed the home button!", Toast.LENGTH_LONG).show();
return true;
}
return super.onKeyDown(keyCode, event);
}
来源:https://stackoverflow.com/questions/22318336/how-to-block-home-button-on-android-4-4