Skip to content

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

@joan-pm

Description

@joan-pm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions