Android: Disallow multiple launcher activities

This commit is contained in:
Ryan Meredith 2020-06-16 11:52:58 -04:00
parent 4c64e18b24
commit 1e6925e423
2 changed files with 17 additions and 0 deletions

View File

@ -73,6 +73,7 @@ public final class EmulationActivity extends AppCompatActivity
private boolean mDeviceHasTouchScreen; private boolean mDeviceHasTouchScreen;
private boolean mMenuVisible; private boolean mMenuVisible;
private static boolean sIgnoreLaunchRequests = false;
private static boolean sIsGameCubeGame; private static boolean sIsGameCubeGame;
private boolean activityRecreated; private boolean activityRecreated;
@ -196,6 +197,11 @@ public final class EmulationActivity extends AppCompatActivity
public static void launch(FragmentActivity activity, GameFile gameFile) public static void launch(FragmentActivity activity, GameFile gameFile)
{ {
if (sIgnoreLaunchRequests)
return;
sIgnoreLaunchRequests = true;
Intent launcher = new Intent(activity, EmulationActivity.class); Intent launcher = new Intent(activity, EmulationActivity.class);
launcher.putExtra(EXTRA_SELECTED_GAMES, scanForSecondDisc(gameFile)); launcher.putExtra(EXTRA_SELECTED_GAMES, scanForSecondDisc(gameFile));
@ -207,6 +213,11 @@ public final class EmulationActivity extends AppCompatActivity
public static void launchFile(FragmentActivity activity, String[] filePaths) public static void launchFile(FragmentActivity activity, String[] filePaths)
{ {
if (sIgnoreLaunchRequests)
return;
sIgnoreLaunchRequests = true;
Intent launcher = new Intent(activity, EmulationActivity.class); Intent launcher = new Intent(activity, EmulationActivity.class);
launcher.putExtra(EXTRA_SELECTED_GAMES, filePaths); launcher.putExtra(EXTRA_SELECTED_GAMES, filePaths);
@ -237,6 +248,11 @@ public final class EmulationActivity extends AppCompatActivity
activity.startActivity(launcher); activity.startActivity(launcher);
} }
public static void stopIgnoringLaunchRequests()
{
sIgnoreLaunchRequests = false;
}
public static void clearWiimoteNewIniLinkedPreferences(Context context) public static void clearWiimoteNewIniLinkedPreferences(Context context)
{ {
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit(); SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();

View File

@ -411,6 +411,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
Log.debug("[EmulationFragment] Starting emulation thread."); Log.debug("[EmulationFragment] Starting emulation thread.");
NativeLibrary.Run(mGamePaths); NativeLibrary.Run(mGamePaths);
} }
EmulationActivity.stopIgnoringLaunchRequests();
}, "NativeEmulation"); }, "NativeEmulation");
emulationThread.start(); emulationThread.start();
} }