Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #7319 from zackhow/exit-double
Android: require back to be pressed twice to exit on mobile
  • Loading branch information
delroth committed Aug 12, 2018
2 parents a2b9766 + a2f90d3 commit 3bf92e7
Showing 1 changed file with 12 additions and 3 deletions.
Expand Up @@ -78,6 +78,7 @@ public final class EmulationActivity extends AppCompatActivity
private String mSelectedTitle;
private int mPlatform;
private String mPath;
private boolean backPressedOnce = false;

public static final String EXTRA_SELECTED_GAME = "SelectedGame";
public static final String EXTRA_SELECTED_TITLE = "SelectedTitle";
Expand Down Expand Up @@ -329,10 +330,18 @@ public void onBackPressed()
}
else
{
mEmulationFragment.stopEmulation();
exitWithAnimation();
if (backPressedOnce)
{
mEmulationFragment.stopEmulation();
exitWithAnimation();
}
else
{
backPressedOnce = true;
Toast.makeText(this, "Press back again to exit", Toast.LENGTH_LONG).show();
new Handler().postDelayed(() -> backPressedOnce = false, 3000);
}
}

}

@Override
Expand Down

0 comments on commit 3bf92e7

Please sign in to comment.