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

Error calling startActivity() on RNFetchBlob.android.actionViewIntent to intent files. #435

Closed
bitter-jm opened this issue Sep 9, 2019 · 3 comments

Comments

@bitter-jm
Copy link

bitter-jm commented Sep 9, 2019

Warning:
Error: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag.

Versions:

  • rn-fetch-blob: 0.10.16
  • react-native: 0.60.4

Code:

.fetch('GET', adj.url, {Authorization:`Bearer ${newToken}`})
.then((res) => {
  if (adj.tipus_mime == 'application/pdf') {
    RNFetchBlob.android.actionViewIntent(res.path(), 'application/pdf')
  }
  else {
    // ....
  }
}).catch((err) => {/*   ...   */});

It downloads the file correctly but when executing RNFetchBlob.android.actionViewIntent() it rises an error due to a lack of a flag. I've seen the same error in this issue: #317 and the solution proposed is to add intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); inside android/src/main/java/com/RNFetchBlob/RNFetchBlob.java file. The problem is that this folder android/src/main/java/com/RNFetchBlob does not exist in my project.

Edit note: This code worked properly in previous versions of Android but not in Android 9.

@Gutyn
Copy link

Gutyn commented Sep 11, 2019

@joan3pastor did you manage to fix it?

@ganesh98a
Copy link

@joan3pastor Pls look into this it may helps you - #317

@bitter-jm
Copy link
Author

Closing coz of redundancy. #317 solved my problem by it would be nice to merge those changes to main branch.

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

No branches or pull requests

3 participants