Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
Add the FLAG_ACTIVITY_NEW_TASK flag.
Browse files Browse the repository at this point in the history
This is caused by an error on Android 9: 'Error: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?'
  • Loading branch information
wakeless committed Mar 7, 2019
1 parent d8c79f6 commit 0b47f3d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion android/src/main/java/com/RNFetchBlob/RNFetchBlob.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public void actionViewIntent(String path, String mime, final Promise promise) {
// Set flag to give temporary permission to external app to use FileProvider
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

// All the activity to be opened outside of an activity
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// Validate that the device can open the file
PackageManager pm = getCurrentActivity().getPackageManager();
if (intent.resolveActivity(pm) != null) {
Expand Down Expand Up @@ -410,4 +412,4 @@ public void getSDCardDir(Promise promise) {
public void getSDCardApplicationDir(Promise promise) {
RNFetchBlobFS.getSDCardApplicationDir(this.getReactApplicationContext(), promise);
}
}
}

1 comment on commit 0b47f3d

@CoreyBovalina
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance this can be merged into version 0.10.15? We can't use RN .60 yet, but I just ran into this issue and made the change locally and it fixed it.

Please sign in to comment.