简体   繁体   English

如何在棒棒糖中禁用Android设备的主页按钮

[英]How to disable home button of Android device in lollipop

我想拦截棒棒糖版本的Android设备的主页按钮单击。

I think this can be done in another style if suits your requirement. 我认为,如果适合您的要求,可以用另一种方式完成。 By creating your activity as home activity. 通过将您的活动创建为家庭活动。 If you want to disable home button and show your custom application activity as launcher when home button is 如果要禁用主页按钮,并在按下主页按钮时将自定义应用程序活动显示为启动器
pressed. 按下。 Just add these lines in manifest for that activity for which you want your launcher. 只需在清单中为您想要启动器的活动添加这些行。

 <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>

if user presses the home button, Android will ask for which launcher you want your home. 如果用户按下主页按钮,则Android会询问您要回家的启动器。 Then your have to select your application launcher ALWAYS not ONLY ONCE. 然后,您必须仅选择一次应用程序启动器。

if you want fully disable the user, so that he cant move to another screen then set theme to fullscreen with NoTilebar. 如果要完全禁用该用户,以使其无法移动到另一个屏幕,请使用NoTilebar将主题设置为全屏。

Use this method: 使用此方法:

@Override
public void onAttachedToWindow() {
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
    super.onAttachedToWindow();
};

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

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