Double back press exit from app In Android Studio -

int this tutorials you will learn how to implement Double back press exit from app in android studio projects.

Add In Your java file activity

Paste this code up to last closing brasher



boolean doubleBackToExitPressedOnce = false;


    public void onBackPressed() {

        if (doubleBackToExitPressedOnce) {





        this.doubleBackToExitPressedOnce = true;

        Toast.makeText(this, "Please click BACK again to exit", Toast.LENGTH_SHORT).show();


        new Handler().postDelayed(new Runnable() {



            public void run() {



        }, 2000);