Skip to content

Share plugin has weird behavior on Android #1466

@diesieben07

Description

@diesieben07

Bug Report

Plugin(s)

Share

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 4.7.0
  @capacitor/core: 4.7.0
  @capacitor/android: 4.7.0
  @capacitor/ios: 4.7.0

Installed Dependencies:

  @capacitor/cli: 4.5.0
  @capacitor/core: 4.5.0
  @capacitor/ios: 4.5.0
  @capacitor/android: 4.5.0

Platform(s)

Android

Current Behavior

When sharing content using the Share plugin, the target app's activity is opened within the context of the source app, leading to very confusing UI behavior:

  • In the task overview ("list of open apps"), the target app and the source app are not separate. The target app is not shown as its own entry, instead its activity is shown as if it was part of the source app
  • If the target app was already open when sharing, it now seems to appear twice in the task overview, due to the issue above.
  • To return to the source app after sharing, the user must use the back button/gesture of the device to step through the history of the target app before then returning to the source app

Expected Behavior

When sharing, the target app should be started as a new task.

Code Reproduction

Share.share({
  title: "Share test",
  text: "I am sharing this text"
});

Additional Context

To fix this, the sharing Intent should be created with the Intent.FLAG_ACTIVITY_NEW_TASK) flag.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions