dolphin/Source/Android
bug 57014eec4d Allow frontends to launch a new game without force closing Dolphin
Original message:
Hey devs,

I'm moth, lead developer of the Cocoon Frontend

For our now playing integration, we're trying to maximise compatability for launching & swapping games without the user having to force close out of the activity.

Dolphin however does not support this at all. No matter what mix of flags and intents I try it just shows the MainActivity.

After a deep dive I found out:
EmulationActivity has an ignoreLaunchRequests check that is set to true until the end of NativeLibrary.Run()
the launch() method returns if its true and just keeps you in MainActivity, never launching the new ROM

This is a problem because Cocoon and other frontends need to use CLEAR_TASK to destroy the existing task and start fresh to load the new ROM.
This destroys EmulationActivity & Fragment but the process still survives so NativeLibrary.Run never returns gracefully.

This makes it so relaunching a new ROM does not work, even if we clear the activity.

Also MainActivity or EmulationActivity doesnt handle onNewIntent()

This would be the graceful way to handle it so we can use CLEAR_TOP | SINGLE_TOP without being ignored.

The two fixes are:

in StartupHandler.HandleInit(), reset the flag before launching so the cleared task's limbo state of ignoreLaunchRequests is reset

The more graceful way would be to add

override fun onNewIntent(intent: Intent)
  super.onNewIntent(intent)
  setIntent(intent)
  StartupHandler.HandleInit(this)
}

in your MainActivity

This would let frontends redeliver game intents without destroying the entire task

After implementation:
I added multiple guards to ensure proper synchronicity and ensure emulators and surfaces are finished before starting a new game.

Frontends can now take advantage of NEW_TASK | CLEAR_TASK to launch a new Dolphin game.
2026-03-19 22:37:03 +00:00
..
app Allow frontends to launch a new game without force closing Dolphin 2026-03-19 22:37:03 +00:00
benchmark Android: Use compilerOptions block to specify JVM version 2026-01-01 13:43:38 +01:00
gradle/wrapper Android: Update Gradle Wrapper 2025-11-12 08:13:30 -05:00
jni DolphinQt: Improve Gecko code download failure message 2026-03-03 11:09:39 -05:00
.gitignore android: Regenerate baseline profile module for AGP 8.2.0 2023-12-09 15:44:29 -05:00
build.gradle.kts Android: Update dependencies 2025-11-11 16:48:12 -05:00
code-style-java.xml Android: Update code-style-java for androidx files 2020-09-08 05:59:08 -04:00
gradle.properties Android: Fix Gradle deprecation 2024-05-25 22:13:25 -04:00
gradlew Android: Update Gradle Wrapper 2025-11-12 08:13:30 -05:00
gradlew.bat Android: Update Gradle Wrapper 2025-11-12 08:13:30 -05:00
settings.gradle.kts android: Regenerate baseline profile module for AGP 8.2.0 2023-12-09 15:44:29 -05:00