How to Disable Back Button in Android App

How to Disable Back Button in Android App


In this article, we are going to learn about Disable "Back button" in an Android application.


1. This is how our android application looks like;


2.Project Structure;


3.code

MainActivity.xml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public void onBackPressed() {

    }
}

You can download the app from here;


You can download the full source code of this tutorial here;


Thanks for your comment