【发布时间】:2015-09-08 05:41:08
【问题描述】:
我想拦截棒棒糖版安卓设备的主页按钮点击。
【问题讨论】:
标签: android locking android-homebutton
我想拦截棒棒糖版安卓设备的主页按钮点击。
【问题讨论】:
标签: android locking android-homebutton
如果符合您的要求,我认为这可以以另一种方式完成。经过
将您的活动创建为家庭活动。如果要禁用主页按钮
并在主页按钮打开时将您的自定义应用程序活动显示为启动器
按下。只需在清单中为您想要启动器的活动添加这些行。
<activity
android:name="com.example.TempActivity"
android:clearTaskOnLaunch="true"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:stateNotNeeded="true" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
如果用户按下主页按钮,Android 会询问您想要哪个启动器作为主页。然后你必须选择你的应用程序启动器,而不仅仅是一次。
如果你想完全禁用用户,这样他就不能移动到另一个屏幕 然后使用 NoTilebar 将主题设置为全屏。
【讨论】:
使用这个方法:
@Override
public void onAttachedToWindow() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
};
【讨论】: