0

我认为我的问题很难理解,但这里有一个简单的例子来理解我想要什么

上面这个方法是在生成新类扩展Activity时默认创建的,在android中点击Menu Button时可以显示菜单

public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        Log.i("---------------", "----------onCreateOptionsMenu--------------");
        return true;

    }

我的目的是创建一个方法,如 onCreateOptionsMenu,但用于 Android 手机中的 Home Button

4

2 回答 2

4

主页按钮不能被覆盖。唯一的选择是编写自定义主页启动器。

于 2013-04-22T18:23:22.730 回答
1

There is no way to intercept the home button on Android, unless you make your app the home screen. This is for security reasons, so that malicious apps cannot take over your device by overriding all the buttons that can exit. The home button is the one sure shot way to be able to leave any app.

If you want to handle the HOME button, implement a home screen.

Override home and back button is case a boolean is true

Check the above link and check the comments also. The approach in the link does not work on ICS.

Useful links

Disable Home Button in Android ICS (4.0)

How can I disable Android 4.0 home button?

于 2013-04-22T18:25:52.770 回答