浏览代码

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?'
Michael Gall 6 年前
父节点
当前提交
0b47f3d34a
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3
    1
      android/src/main/java/com/RNFetchBlob/RNFetchBlob.java

+ 3
- 1
android/src/main/java/com/RNFetchBlob/RNFetchBlob.java 查看文件

120
                 // Set flag to give temporary permission to external app to use FileProvider
120
                 // Set flag to give temporary permission to external app to use FileProvider
121
                 intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
121
                 intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
122
 
122
 
123
+                // All the activity to be opened outside of an activity
124
+                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
123
                 // Validate that the device can open the file
125
                 // Validate that the device can open the file
124
                 PackageManager pm = getCurrentActivity().getPackageManager();
126
                 PackageManager pm = getCurrentActivity().getPackageManager();
125
                 if (intent.resolveActivity(pm) != null) {
127
                 if (intent.resolveActivity(pm) != null) {
410
     public void getSDCardApplicationDir(Promise promise) {
412
     public void getSDCardApplicationDir(Promise promise) {
411
         RNFetchBlobFS.getSDCardApplicationDir(this.getReactApplicationContext(), promise);
413
         RNFetchBlobFS.getSDCardApplicationDir(this.getReactApplicationContext(), promise);
412
     }
414
     }
413
-}
415
+}