Android: require back to be pressed twice to exit on mobile
This commit is contained in:
parent
a2b97665bb
commit
a2f90d3915
|
@ -78,6 +78,7 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
private String mSelectedTitle;
|
private String mSelectedTitle;
|
||||||
private int mPlatform;
|
private int mPlatform;
|
||||||
private String mPath;
|
private String mPath;
|
||||||
|
private boolean backPressedOnce = false;
|
||||||
|
|
||||||
public static final String EXTRA_SELECTED_GAME = "SelectedGame";
|
public static final String EXTRA_SELECTED_GAME = "SelectedGame";
|
||||||
public static final String EXTRA_SELECTED_TITLE = "SelectedTitle";
|
public static final String EXTRA_SELECTED_TITLE = "SelectedTitle";
|
||||||
|
@ -329,10 +330,18 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mEmulationFragment.stopEmulation();
|
if (backPressedOnce)
|
||||||
exitWithAnimation();
|
{
|
||||||
|
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
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue