我可以覆盖在我的应用程序中的“主页”按钮?我的、应用程序、按钮、主页

2023-09-11 12:08:35 作者:过往丶一文不值

我想在我的Andr​​oid创建我自己的'家'屏幕,我要调用的主屏幕,从我的应用程序。

I want to create my own 'home' screen on my android, and I want to call that home screen from my application.

我如何重写主页按钮,这样,当它是pressed应用程序将被重定向到我的主屏幕,而不是默认主屏幕?是否有可能重写home键?

How can I override the 'Home' button so that when it's pressed the application will be redirected to my home screen instead of the default home screen? Is it possible to override the home button?

推荐答案

您好再次 您可以覆盖home键任何其他按钮:

Hi again You can override the home button as any other 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);
}