Quellcode durchsuchen

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 vor 5 Jahren
Ursprung
Commit
0b47f3d34a
Es ist kein Benutzerkonto mit dieser Commiter-Email verbunden
1 geänderte Dateien mit 3 neuen und 1 gelöschten Zeilen
  1. 3
    1
      android/src/main/java/com/RNFetchBlob/RNFetchBlob.java

+ 3
- 1
android/src/main/java/com/RNFetchBlob/RNFetchBlob.java Datei anzeigen

@@ -120,6 +120,8 @@ public class RNFetchBlob extends ReactContextBaseJavaModule {
120 120
                 // Set flag to give temporary permission to external app to use FileProvider
121 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 125
                 // Validate that the device can open the file
124 126
                 PackageManager pm = getCurrentActivity().getPackageManager();
125 127
                 if (intent.resolveActivity(pm) != null) {
@@ -410,4 +412,4 @@ public class RNFetchBlob extends ReactContextBaseJavaModule {
410 412
     public void getSDCardApplicationDir(Promise promise) {
411 413
         RNFetchBlobFS.getSDCardApplicationDir(this.getReactApplicationContext(), promise);
412 414
     }
413
-}
415
+}