How to block home button on Android 4.4?

佐手、 提交于 2019-12-13 07:33:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!