我不想让应用程序在后台运行。 当用户按下Android设备上的主页按钮时,应该完成当前活动。关闭android设备的主页按钮上的当前活动点击
或者当应用程序恢复时,我想知道应用程序已经成为前台。
我已经创建了接收器在<应用>标签清单文件:
<receiver
android:name=".HomeKeyReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</receiver>
不过这个接收器是没有得到调用。如果这个接收器被调用,我可以关闭应用程序。
检查答案在:http://stackoverflow.com/a/4784134/1434631 并阅读:http://stackoverflow.com/questions/2079691/overriding-the-home-button-how-do我摆脱了选择 – Nermeen