Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[@capacitor/share] "Can't share while sharing is in progress" when sharing to the same app on Android

未关闭
#2,424 1 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
58/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
android, java
领域
mobile

调研方向

从 Android SharePlugin 实现开始,跟踪 share()、activityResult()、isPresenting 和 handleOnNewIntent(),注意 MainActivity 如何为 ACTION_SEND 重用。使用链接的示例应用重现该问题,然后验证传入的 share 会重置进行中的状态,并且后续 share 能够成功。

由索引模型根据 Issue 内容生成。

描述

platform: android

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 MainActivity with the ACTION_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, isPresenting flag isn't reset, and all subsequent calls to share() would throw error Can'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;
    }
}
主要语言
Java
星标
682
派生
689
平均合并
5 天 11 小时
30 天内合并 PR
3

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ionic-team/capacitor-plugins 的其他 Issue

查看 ionic-team/capacitor-plugins 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。