Skip to content

[Android] Fix actionViewIntent for SDK < 24 #685

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

Merged
merged 1 commit into from
Apr 4, 2022

Conversation

Chris-Guy
Copy link

@Chris-Guy Chris-Guy commented Oct 16, 2020

actionViewIntent does not work for SDK < 24

It seems that this part of the code was introduced when migrating to Android file providers: wkh237#358
The blog post about it: https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en says that from the moment we set targetSdkVersion to something superior to 24, we need to pass through a file provider: "This behavior will happen only when you change your app's targetSdkVersion to 24 or above".

I imagine that the dev that implemented it thinking (with good will) that he needed to separate the two flows depending on the device Android SDK version at the runtime, but now that the default config is set as 28 in the build.gradle, we should remove this logic. File providers are meant to work even for Android SDK < 24, it all depends on the target version set when we build.

Also, I take some part of the PR for [Android] Promise resolve and reject for actionViewIntent (#535) as it is very useful to have a promise rejection when the intent is not resolved (kudos to MikeChugunov)

@Chris-Guy Chris-Guy changed the title [Android] Fix actionViewIntent for OS <= 6 [Android] Fix actionViewIntent for SDK < 24 Oct 16, 2020
@bitcrumb
Copy link

I stumbled upon this issue today as well. Took me a good while before realising. However, since this library is now marked as unmaintained, I wouldn't expect this to get merged :(

@R4DIC4L
Copy link

R4DIC4L commented Jan 26, 2021

Someone forked this project to continue working on it: https://github.com/RonRadtke/react-native-blob-util. Maybe suggesting this fix there would help.

I have also had this problem in android and solved it by forking react-native-open-doc and adding a function openWithSuggestedMime to use OPEN_DOCUMENT instead of ACTION_VIEW. I then released a public npm package with this fix. I was also using react-native-document-picker and react-native-image-picker which already provide me the file's mime type.

@bitcrumb
Copy link

@R4DIC4L Thanks for such a swift response! I'll look into the alternatives. Thanks man, much appreciated :)

@rpenfold rpenfold merged commit 28f4a54 into joltup:master Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants