Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: fix sharing a single file #984

Merged

Conversation

roman-r-m
Copy link
Contributor

@roman-r-m roman-r-m commented Mar 20, 2021

This is a follow-up to my previous PR #968 - looks like I have introduced a bug there.
According to the official dev guide we only need to set the type, and the URI goes to EXTRA_STREAM.

Without this change if I share a file to, say Gmail, I get a new email with the subject containing the URI which is clearly wrong. After the fix, as expected, I get a new email with the file attached.

Fixes #976

@MateusAndrade
Copy link
Collaborator

Thanks!

@MateusAndrade MateusAndrade merged commit cccfca7 into react-native-share:master Mar 22, 2021
MateusAndrade pushed a commit that referenced this pull request Mar 22, 2021
## [5.1.5](v5.1.4...v5.1.5) (2021-03-22)

### Bug Fixes

* android sharing a single file ([#984](#984)) ([cccfca7](cccfca7))
@MateusAndrade
Copy link
Collaborator

🎉 This PR is included in version 5.1.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@yfunk
Copy link

yfunk commented Jul 19, 2021

@roman-r-m @MateusAndrade It seems like this PR introduced a regression of the fix in the previous PR #968.

I was getting the SecurityException on v6.3.0 and found the previous PR during troubleshooting. I then downgraded the library v5.1.3 (where the first previous PR was added) and the error was gone. After upgrading to v5.1.5 (next change to android/src/main/java/cl/json/social/ShareIntent.java) which added this PR the error was getting thrown again.

2021-07-19 16:09:51.019 7918-7942/com.myapp E/DatabaseUtils: Writing exception to parcel
    java.lang.SecurityException: Permission Denial: reading cl.json.RNShareFileProvider uri content://com.myapp.rnshare.fileprovider/rnshare2/export/test.zip from pid=314, uid=1000 requires the provider be exported, or grantUriPermission()
        at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:729)
        at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:602)
        at android.content.ContentProvider$Transport.query(ContentProvider.java:231)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:104)
        at android.os.Binder.execTransactInternal(Binder.java:1021)
        at android.os.Binder.execTransact(Binder.java:994)

Although I didn't notice any issues related to sharing with a Base64 image or ~250MB zip archive. The same issue occurred over at flutter_share, here's how they fixed it.

Environment:

react-native: 0.64.2
react-native-share: 5.1.5 - 6.3.0
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30

Tested on Emulator (API 29) and Samsung Galaxy M20 (API 29)

mobiledev7 added a commit to mobiledev7/react-native-share that referenced this pull request Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Facing Issue while sharing in GMAIL( TO address bar is pre-populated)
3 participants