Android - How to Disable the Click of Home Button

Can I disable home button On Android

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>

How to partially disable click on home button in Android toolbar?

You should return true to say the parent that the click on the menu item is consumed.

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
android.R.id.home -> {
if (mode) {
reset()
return true
}
}
}
return super.onOptionsItemSelected(item)
}

How to disable the home key

Use this method to disable the Home key in android

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


Related Topics



Leave a reply



Submit