Jul 20, 2021

Double back press exit from app In Android Studio - Androidpro.in

Double back press exit from app

Add In Your java file activity main.java

Paste this code up to last closing brasher

 
boolean doubleBackToExitPressedOnce = false;
 
    @Override
    public void onBackPressed() {
        if (doubleBackToExitPressedOnce) {
            super.onBackPressed();
            return;
        }
 
        this.doubleBackToExitPressedOnce = true;
        Toast.makeText(this, "Please click BACK again to exit", Toast.LENGTH_SHORT).show();
 
        new Handler().postDelayed(new Runnable() {
 
            @Override
            public void run() {
                doubleBackToExitPressedOnce=false;
            }
        }, 2000);
    }

 


Whatsapp Button works on Mobile Device only