Skip to content

Commit a09694d

Browse files
Ron RadtkeRon Radtke
authored andcommitted
Merge commit '916d1f5dcad911258f6005b39d7def7c2645eab7'
# Conflicts: # android/src/main/java/com/RNFetchBlob/RNFetchBlob.java
2 parents 61615e2 + 916d1f5 commit a09694d

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

README.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -588,22 +588,14 @@ RNFetchBlob.config({
588588
})
589589
.fetch('GET', `http://www.example.com/awesome.apk`)
590590
.then((res) => {
591-
android.actionViewIntent(res.path(), 'application/vnd.android.package-archive').then(() => {
592-
console.log('File opened')
593-
}).catch(e => {
594-
console.warn('Unable to open file', e);
595-
})
591+
android.actionViewIntent(res.path(), 'application/vnd.android.package-archive')
596592
})
597593
```
598594

599595
Or show an image in image viewer
600596

601597
```js
602-
android.actionViewIntent(PATH_OF_IMG, 'image/png').then(() => {
603-
console.log('File opened')
604-
}).catch(e => {
605-
console.warn('Unable to open file', e);
606-
})
598+
android.actionViewIntent(PATH_OF_IMG, 'image/png')
607599
```
608600

609601
## File System

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ public void actionViewIntent(String path, String mime, @Nullable String chooserT
129129

130130
// Validate that the device can open the file
131131
PackageManager pm = getCurrentActivity().getPackageManager();
132+
if (intent.resolveActivity(pm) != null) {
133+
this.getReactApplicationContext().startActivity(intent);
134+
}
135+
132136
} else {
133137
Intent intent = new Intent(Intent.ACTION_VIEW)
134138
.setDataAndType(Uri.parse("file://" + path), mime).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

0 commit comments

Comments
 (0)