0

My current code exits application if press double back button and now I want to change it so that it just minimize app on double click. Just like how pressing a home button.

This is the code:

@Override
public void onBackPressed() {
    if (doubleBackToExitPressedOnce) {
        super.onBackPressed();
        return;
    }
    final View coordinatorLayoutView = findViewById(R.id.coordinator);
    Snackbar.make(coordinatorLayoutView, "Press again to minimize app.", Snackbar.LENGTH_LONG).show();

    this.doubleBackToExitPressedOnce = true;

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

        @Override
        public void run() {
            // This is where I need code
            doubleBackToExitPressedOnce = false;
        }
    }, 2000);
}
Sufian
  • 6,405
  • 16
  • 66
  • 120

1 Answers1

0

This seems like a really unlikely and confusing event, the user can put the app in the background anytime by the Android buttons at the bottom.

Doppie
  • 95
  • 1
  • 8