简体   繁体   English

如何将我的应用设置为默认主页?

[英]How to set my App as default Home?

I'm developing a Android desktop app, and I would like that when it first starts it (confirm with user and) set itself as default action for Home button. 我正在开发一个Android桌面应用程序,我希望它在首次启动时(与用户确认)并将其自身设置为“主页”按钮的默认操作。

Currently, this option is given to the user by the Android system only when he first press the Home button after running my app. 当前,只有当用户在运行我的应用程序后首次按下“主页”按钮时,该选项才由Android系统提供给该用户。

Actually, I want the "back" button to not return to the default desktop, as my app will be the default desktop. 实际上,我希望“后退”按钮不返回默认桌面,因为我的应用程序将是默认桌面。 Maybe the solution for this is the same of the one for the Home button? 也许此解决方案与“主页”按钮的解决方案相同?

Any idea how to do this? 任何想法如何做到这一点?

你不可以做这个。

Why not just let the system do it for you when the user presses the Home button for the first time. 当用户第一次按下“主页”按钮时,为什么不让系统为您做呢? It's what the user is expecting. 这就是用户的期望。 He/she doesn't expect it to change automatically and personally I would find that quite annoying if it did that since I like choosing my Home screen constantly. 他/她并不希望它会自动更改,而且我个人认为这样做会很烦人,因为我喜欢不断选择自己的主屏幕。

As for the back button, simply add an onKeyDown/Up handler for the KeyEvent.KEYCODE_BACK event to return true (meaning handled by you, not the system). 至于后退按钮,只需为KeyEvent.KEYCODE_BACK事件添加一个onKeyDown/Up处理程序即可返回true (意味着由您而非系统处理)。 If you do that, it will not leave your app. 如果这样做,它将不会离开您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM