-
Notifications
You must be signed in to change notification settings - Fork 141
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] actionViewIntent - activity won't start on Android 11+ #78
Comments
I created a patch if someone want to test fix: I can create a PR if confirmed. |
Successfully applied and tested this patch in my project. Using |
However, using the solution described in this closed issue also fixes it for me. Not sure which of these is the way to go. |
@Aure77 would you be so kind to create a PR, I would merge it and create a new update for the lib then. It's the better way to go. Adjusting the manifest is just a fix for some basically wrong behavior of the lib. |
If your app target Android API 30+ (and use Android 11 device),
using
ReactNativeBlobUtil.android.actionViewIntent(path, "application/pdf");
may do nothing.After investing code,
startActivity
is not called becauseresolveActivity
always returnnull
here:react-native-blob-util/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtil.java
Lines 135 to 137 in 93059e0
This is due to new Android 11 package visibility.
I found a very interesting article that recommend do no not use resolveActivity - startActivity pattern to avoid potential issues.
See: https://cketti.de/2020/09/03/avoid-intent-resolveactivity/
Why not using try catch method for all Android version like here:
react-native-blob-util/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtil.java
Lines 145 to 150 in 93059e0
and that handle promise resolve/reject correctly.
(this workaround fix my issue with Android 11+ devices)
Full example to reproduce:
Further more,
actionViewIntent
promise is only resolved for Android SDK < 24react-native-blob-util/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtil.java
Line 147 in 93059e0
Is this normal ?
The text was updated successfully, but these errors were encountered: