我在我的应用程序,我必须控制后退按钮,但我也想控制home键。我已经写了code,但我无法控制HOME按钮。这是我的code。帮我实现了。
公共布尔的onkeydown(INT键code,KeyEvent的事件)
{
如果(键code == KeyEvent.KEY code_BACK)
{
返回false;
}
否则,如果(键code == KeyEvent.KEY code_HOME)
{
返回false;
}
返回super.onKeyDown(键code,事件);
}
解决方案
您不能覆盖home键的功能,该功能将允许一个应用程序来锁定用户从手机。
I am in my application and I have control back button but I also want to control home button. I have written the code but I am unable to control HOME button. Here is my code. Help me to achieve it.
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK )
{
return false;
}
else if (keyCode == KeyEvent.KEYCODE_HOME)
{
return false;
}
return super.onKeyDown(keyCode, event);
}
解决方案
You cannot override the home key function, this functionality would allow an app to lock the user out of the phone.