Skip to content

Commit 0b47f3d

Browse files
committed
Add the FLAG_ACTIVITY_NEW_TASK flag.
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?'
1 parent d8c79f6 commit 0b47f3d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

android/src/main/java/com/RNFetchBlob/RNFetchBlob.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ public void actionViewIntent(String path, String mime, final Promise promise) {
120120
// Set flag to give temporary permission to external app to use FileProvider
121121
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
122122

123+
// All the activity to be opened outside of an activity
124+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
123125
// Validate that the device can open the file
124126
PackageManager pm = getCurrentActivity().getPackageManager();
125127
if (intent.resolveActivity(pm) != null) {
@@ -410,4 +412,4 @@ public void getSDCardDir(Promise promise) {
410412
public void getSDCardApplicationDir(Promise promise) {
411413
RNFetchBlobFS.getSDCardApplicationDir(this.getReactApplicationContext(), promise);
412414
}
413-
}
415+
}

0 commit comments

Comments
 (0)