Skip to content

Commit 699b808

Browse files
authored
Add onNewIntent handler to support launching games with FLAG_ACTIVITY_CLEAR_TOP (#18210)
Enables launchers to use the FLAG_ACTIVITY_CLEAR_TOP launch flag to open games. It checks if the launched game is already running or if it's a new game to launch over the existing one. This provides an alternative to launchers using FLAG_ACTIVITY_CLEAR_TASK which results in a crash on many Android 13 devices if RetroArch is already running in the background.
1 parent 2494e9a commit 699b808

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

pkg/android/phoenix/src/com/retroarch/browser/retroactivity/RetroActivityFuture.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,39 @@ public void onCreate(Bundle savedInstanceState) {
6262
quitfocus = getIntent().hasExtra("QUITFOCUS");
6363
}
6464

65+
@Override
66+
public void onNewIntent(Intent intent) {
67+
super.onNewIntent(intent);
68+
69+
// Check if this intent contains game launch parameters
70+
String newRom = intent.getStringExtra("ROM");
71+
String newCore = intent.getStringExtra("LIBRETRO");
72+
73+
// Get current intent parameters for comparison
74+
Intent currentIntent = getIntent();
75+
String currentRom = currentIntent != null ? currentIntent.getStringExtra("ROM") : null;
76+
String currentCore = currentIntent != null ? currentIntent.getStringExtra("LIBRETRO") : null;
77+
78+
// Check if we're trying to launch different content
79+
boolean isDifferentContent = false;
80+
if (newRom != null && !newRom.equals(currentRom)) {
81+
isDifferentContent = true;
82+
}
83+
if (newCore != null && !newCore.equals(currentCore)) {
84+
isDifferentContent = true;
85+
}
86+
87+
if (isDifferentContent) {
88+
// Exit cleanly and let the system restart us with new content
89+
finish();
90+
System.exit(0);
91+
} else {
92+
// Same content, just update intent
93+
setIntent(intent);
94+
}
95+
}
96+
97+
6598
@Override
6699
public void onResume() {
67100
super.onResume();

0 commit comments

Comments
 (0)