简体   繁体   English

菜单或“警报对话框”弹出时如何禁用主页键?

[英]How to disable the home key when the menu or Alarm Dialog pop up?

How to disable the home key when the menu or Alarm Dialog pop up? 菜单或“警报对话框”弹出时如何禁用主页键? I know how to disable the home key in the activity. 我知道如何在活动中禁用Home键。 But when the menu or Alarm Dialog pop up, the way is invalid. 但是当菜单或“警报对话框”弹出时,方法无效。 How to implement this function. 如何实现此功能。 Or is there no way to deal with this case? 还是没有办法处理这种情况?

You can not disable Home Key . 您不能禁用Home Key。 for this is the last chance the Android System ESCAPE the application. 这是Android System ESCAPE应用程序的最后机会。

I had the same requirement in my project. 我在项目中有相同的要求。 Here is my solution: 这是我的解决方案:

1) You should have a rooted device. 1)您应该有一个植根设备。

2) Make sure that your activity is main activity, it should have params like these: 2)确保您的活动是主要活动,它应具有以下参数:

<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />

If you have it, when you tap home button android suggest you other apps except Launcher... 如果有的话,当您点击主屏幕按钮android时,建议您启动器以外的其他应用程序...

3) Next, since we have rooted device, just find and rename Launcher.apk to LauncerBBB.apk(it can be done programmatically even). 3)接下来,由于我们已经扎根设备,只需找到并将Launcher.apk重命名为LauncerBBB.apk(甚至可以通过编程方式完成)。

4) That's all. 4)仅此而已。 Now only your app is main and it will be shown by Home key tap. 现在,只有您的应用程序是主应用程序,它将通过Home键水龙头显示。

PS If you need to have an access to Launcher you can start LauncerBBB activity from secret menu of your application. PS如果需要访问Launcher,则可以从应用程序的秘密菜单启动LauncerBBB活动。

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

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