[@capacitor/share] "Can't share while sharing is in progress" when sharing to the same app on Android
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 58/100
Research direction
Start with the Android SharePlugin implementation and trace share(), activityResult(), isPresenting, and handleOnNewIntent(), paying attention to how MainActivity is reused for ACTION_SEND. Reproduce the issue with the linked sample app, then verify that an incoming share resets the in-progress state and that subsequent shares succeed.
Written by the indexing model from the issue text.
Description
Bug Report
Plugin(s)
@capacitor/share
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 7.4.3
@capacitor/core: 7.4.3
@capacitor/android: 7.4.3
@capacitor/ios: 7.4.3
Installed Dependencies:
@capacitor/ios: not installed
@capacitor/cli: 7.4.3
@capacitor/core: 7.4.3
@capacitor/android: 7.4.3
[success] Android looking great! 👌
Platform(s)
Android
Current Behavior
In my app I have both outgoing + incoming share functionality. When I try to share anything to the same app, the plugin's Android implementation becomes stuck in some "in-progress" state, and subsequent share calls immediately fail with error:
Can't share while sharing is in progress
Expected Behavior
All subsequent shares from the app into same app work OK.
Code Reproduction
I've prepared reproduction repo - please check out https://github.com/dmitry-salnikov/capacitor-share-plugin-bug-reproduction
Other Technical Details
Android only, everything works OK on iOS.
Additional Context
The problem
- Android tries to launch
MainActivitywith theACTION_SEND intent. - Because
launchMode="singleTask", Android doesn't create a new activity instance. Instead, it reuses the existing task and brings it to the front. - Since the activity never finishes (it's the same instance),
activityResult()is never called. - This way,
isPresentingflag isn't reset, and all subsequent calls toshare()would throw errorCan't share while sharing is in progress.
The solution
Handle incoming share intent in SharePlugin's code to reset isPresenting flag and resolve plugin call, e.g.:
@Override
protected void handleOnNewIntent(Intent intent) {
if (isPresenting && intent != null && Intent.ACTION_SEND.equals(intent.getAction())) {
PluginCall call = bridge.getSavedCall("activityResult");
if (call != null) {
call.resolve(new JSObject().put("activityType", ""));
}
isPresenting = false;
}
}
- Dominant language
- Java
- Stars
- 682
- Forks
- 689
- Avg merge
- 5d 11h
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ionic-team/capacitor-plugins
-
[@capacitor/app] iOS: 'Expression implicitly coerced from String? to Any' warning in getAppLanguageOpentriage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
ionic-team/capacitor-plugins#2604 ·
-
platform: ios
Difficulty 4/5 3-5 days Newbie friendliness 58/100
ionic-team/capacitor-plugins#2603 · 1 comment ·
-
platform: android
Difficulty 3/5 1-2 days Newbie friendliness 76/100
ionic-team/capacitor-plugins#2599 ·
-
platform: ios
Difficulty 3/5 1-2 days Newbie friendliness 68/100
ionic-team/capacitor-plugins#2595 · 2 reactions ·
-
platform: android triage
Difficulty 4/5 3-5 days Newbie friendliness 48/100
ionic-team/capacitor-plugins#2593 ·
All issues in ionic-team/capacitor-plugins
Similar issues
-
area/frontend good first issue kind/cooldown
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
beehive-lab/TornadoVM#1151 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
FasterXML/jackson-dataformats-binary#823 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day