如何阻止在Android

如何阻止在Android

本文介绍了如何阻止在Android 4.4 home键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android 4.4的我开发一个锁屏应用程序,但在锁屏的活动,我不能阻止home键。任何人都可以解决吗?

On Android 4.4 I develop a lockscreen app, but in lockscreen activity I can't block home button. Can anyone solve it?

推荐答案

重写活动的onkeydown功能,然后搭上了home键的事件。

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);
}

这篇关于如何阻止在Android 4.4 home键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 02:19
查看更多