Is it possible to completely disable the back button in the entire android application and is it possible to do it individually?
Here is a picture of back button that I think
Is it possible to completely disable the back button in the entire android application and is it possible to do it individually?
Here is a picture of back button that I think
Yes it is possible.
For a single activity, you need to do the following
@Override
public void onBackPressed() {
if (!shouldAllowBack()) {
return;
}
super.onBackPressed();
}
where shouldAllowBack()
will have the logic whether back is allowed or not.
For disabling it through out the application, Just create a parent activity and extend from it in your other activities. Add the above code in the parent activity and you just need to return from onBackPressed()
method. You can refer this example here to know that how to extend an activity.
If you totally want to disable your back button, you can just override the onBackPressed
on your Activity
and Android will know when back button is pressed. So you can just return:
@Override
public void onBackPressed() {
return;
}
With doing it individually I hope you mean programmatically.