Fix double-launch issue when switching games from external launcher (#18587)

When launching a different game via FLAG_ACTIVITY_CLEAR_TOP (e.g., from
Daijishou), onNewIntent() was calling finish() + System.exit(0), which
killed the app without restarting. Users had to tap twice to launch a
new game.

Now starts a fresh activity with FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK
before calling System.exit(0). This queues the new game to launch, then
kills the current process so Android starts fresh.
This commit is contained in:
Matt Akins 2026-01-07 09:21:23 -08:00 committed by GitHub
parent 7145bbe874
commit feb9226ab9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -80,11 +80,13 @@ public final class RetroActivityFuture extends RetroActivityCamera {
String currentCore = currentIntent != null ? currentIntent.getStringExtra("LIBRETRO") : null;
// Check if we're trying to launch different content
// Check if we're trying to launch different content
if ((newRom != null && !newRom.equals(currentRom)) ||
(newCore != null && !newCore.equals(currentCore))) {
// Different game content - exit cleanly and let launcher restart us
finish();
// Different game content - start fresh instance then exit
Intent restartIntent = new Intent(intent);
restartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(restartIntent);
System.exit(0);
} else {
// Same content, just update intent