Hazem
Hazem

Reputation: 352

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؟

Upvotes: 2

Views: 6459

Answers (2)

Hazem
Hazem

Reputation: 352

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>

Upvotes: 2

Darish
Darish

Reputation: 11481

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

Upvotes: 4

Related Questions