Android: require back to be pressed twice to exit on mobile

This commit is contained in:
zackhow 2018-08-11 17:31:52 -04:00
parent a2b97665bb
commit a2f90d3915

@ -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";
@ -328,11 +329,19 @@ public final class EmulationActivity extends AppCompatActivity
}
}
else
{
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