简体   繁体   中英

Can I disable home button On Android

I can not disable home button and Which is next to it in android I tried this code but does not work

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

Do you have any idea for solve this problem? Or Can I hide navigation bar permanently forever؟

I found it. I took a part from here how to disable home button in android? and added one row Which originally existed LAUNCHER row as follow:

<activity android:name=".MainActivity"
        android:clearTaskOnLaunch="true"
        android:excludeFromRecents="true"
        android:launchMode="singleTask"
        android:screenOrientation="portrait"
        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" />
            <category android:name="android.intent.category.LAUNCHER"/>

        </intent-filter>
    </activity>

Can I hide navigation bar permanently forever?

No, system would not allow you to do so. But you can prevent the app from exiting. Do the following in your onPause() method.

 @Override
    protected void onPause() {
        super.onPause();
        ActivityManager activityManager = (ActivityManager) getApplicationContext()
                .getSystemService(Context.ACTIVITY_SERVICE);
        activityManager.moveTaskToFront(getTaskId(), 0);
    }

You need the following permissions

<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.REORDER_TASKS" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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