How to disable onBackPressed button in android

Have you ever wondered how to disable onBackPressed button in android? If you are search for a solution on how to disable onBackPressed button in android, it is as simple as overriding the onBackPressed method of the activity class and commenting out onBackPressed()

import android.os.Bundle;

import com.bluapp.androidview.R;

public class DisableOnBackPressActivity extends AppCompatActivity {

    protected void onCreate(Bundle savedInstanceState) {

    public void onBackPressed(){

By commenting out theĀ super.onBackPressed()method, the android back button is automatically disabled.

If you have any questions or suggestions kindly use the comment box or you can contact us directly through our contact page below.


Add a Comment