#16122·tauri

[bug] [android] Activity callback may be lost, causing the invoke to hang

Author: aiueo13Created Sep 23, 2026Updated Sep 28, 2026
Labelstype: bugplatform: Android

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).

https://github.com/tauri-apps/tauri/blob/023fe7f59650c50b624021460064ee074bda56d9/crates/tauri/mobile/android/src/main/java/app/tauri/plugin/PluginHandle.kt#L46-L54

https://github.com/tauri-apps/tauri/blob/023fe7f59650c50b624021460064ee074bda56d9/crates/tauri/mobile/android/src/main/java/app/tauri/plugin/PluginManager.kt#L152-L155

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:

  1. Defer the new request: set the callback and launch the new Activity after the current Activity finishes.
  2. Do not launch the new Activity and call the new callback with RESULT_CANCELED.
  3. Throw an error.