Skip to content

Commit 7f8ec94

Browse files
authored
Update RNFetchBlob.java
Android to throw an exception when there's no suitable app that can open the file
1 parent deb3588 commit 7f8ec94

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,8 @@ public void actionViewIntent(String path, String mime, final Promise promise) {
120120
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
121121
// All the activity to be opened outside of an activity
122122
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
123-
// Validate that the device can open the file
124-
PackageManager pm = getCurrentActivity().getPackageManager();
125-
if (intent.resolveActivity(pm) != null) {
126-
this.getReactApplicationContext().startActivity(intent);
127-
}
123+
// Don't validate that the intent can run, instead, let it throw an exception if it can't.
124+
this.getReactApplicationContext().startActivity(intent);
128125

129126
} else {
130127
Intent intent = new Intent(Intent.ACTION_VIEW)
@@ -410,4 +407,4 @@ public void getSDCardDir(Promise promise) {
410407
public void getSDCardApplicationDir(Promise promise) {
411408
RNFetchBlobFS.getSDCardApplicationDir(this.getReactApplicationContext(), promise);
412409
}
413-
}
410+
}

0 commit comments

Comments
 (0)