question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

actionViewIntent fails on android 9+

See original GitHub issue
  • react@16.8.6
  • react-native@0.59.8
  • rn-fetch-blob@0.10.15

I am calling my api to get a pdf file:

const { dirs } = RNFetchBlob.fs;
const saveDirectory = Platform.select({ ios: dirs.DocumentDir, android: dirs.DownloadDir });

RNFetchBlob
  .config({ path: `${saveDirectory}/${docName || "temp"}.pdf`})
  .fetch(method, url, headers, body)
  .then(resolve);

It successfully resolves. Then, I try to open it:

RNFB.android.actionViewIntent(pdf, "application/pdf");

After a little bit of waiting I get a YellowBox warning, with a code “EUNSPECIFIED”.

It’s happening on Honor 8x with android 9. Works on OnePlus One with android 6.0.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

9reactions
pavermakovcommented, Jul 17, 2019

Solved it by manipulating with the native java code.

RNFetchBlob.java:

before:

// Set flag to give temporary permission to external app to use FileProvider
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)

after:

// Set flag to give temporary permission to external app to use FileProvider
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

This is actually worth a separate PR.

0reactions
R4DIC4Lcommented, Jan 17, 2021

Maybe for android 9+ an approach using ACTION_OPEN_DOCUMENT is needed instead of ACTION_VIEW as here: https://stackoverflow.com/questions/61356281/android-files-unable-to-get-file-path-from-content-uri-when-file-is-selected-f.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - actionViewIntent fails on android 9+ - - Bountysource
actionViewIntent fails on android 9 + ... I am calling my api to get a pdf file: const { dirs } = RNFetchBlob.fs;...
Read more >
RNFetchBlob.android.actionViewIntent does not working on ...
There is no error thrown. So I can't able to debug. Below is my code: RNFetchBlob.android.actionViewIntent(filePath, mimeType);.
Read more >
Intent - Android Developers
... 9, 8, 7, 6, 5, 4, 3, 2, 1. Class Index · Package Index. android ... Error · ListFormatter.Type · ListFormatter.Width ·...
Read more >
Crash due to file storage on Android 10 and above - Cpming
Crash due to file storage on Android 10 and above ... actionViewIntent(downloadPath ... Target Android 9 (API level 28) or lower.
Read more >
App is not indexable by Google Search; consider adding ...
I am copying and pasting my current working android app project. ... Studio TutorialTags action-view intent filter error, android app error, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found