[bug] [android] Activity callback may be lost, causing the invoke to hang
I’m using a translation tool, so some expressions may be awkward or inaccurate.
Describe the bug
Tauri provides Kotlin API of app.tauri.plugin.Plugin#startActivityForResult and the app.tauri.annotation.ActivityCallback annotation (used to define its callback) for plugin development on Android. These APIs allow a plugin to launch an Android Activity and wait for its result.
However, startActivityForResult is not designed to handle multiple concurrent calls. If startActivityForResult is called again while a previous call is still waiting for its callback, the pending callback is overwritten, leaving the invoke associated with the previous callback unresolved (hanging).
Expected behavior
When another Activity is already open and its callback is still pending, one of the following or others should happen instead of silently overwriting the callback:
- Defer the new request: set the callback and launch the new Activity after the current Activity finishes.
- Do not launch the new Activity and call the new callback with
RESULT_CANCELED. - Throw an error.
Source: tauri-apps/tauri