-
Notifications
You must be signed in to change notification settings - Fork 132
Android API
0.9.0
When sending an ACTION_VIEW
intent with given file path and MIME type, system will try to open an App to handle the file. For example, open Gallery app to view an image, or install APK.
Path of the file to be opened.
Basically system will open an app according to this MIME type.
For example, download and install an APK programatically
const android = RNFetchBlob.android
RNFetchBlob.config({
addAndroidDownloads : {
useDownloadManager : true,
title : 'awesome.apk',
description : 'An APK that will be installed',
mime : 'application/vnd.android.package-archive',
mediaScannable : true,
notification : true,
}
})
.fetch('GET', `http://www.example.com/awesome.apk`)
.then((res) => {
android.actionViewIntent(res.path(), 'application/vnd.android.package-archive')
})
Or show an image in image viewer
android.actionViewIntent(PATH_OF_IMG, 'image/png')
0.10.5
MIME type filter, only the files matches the MIME will be shown.
This method brings up OS default file picker and resolves a file URI when the user selected a file. However, it does not resolve or reject when user dismiss the file picker via pressing hardware back button, but you can still handle this behavior via AppState
Here's an example
let handler = (state) =>{
if(state === 'active') {
console.log('did not select any file, but all good.')
AppState.removeEventListener('change', handler)
}
}
AppState.addEventListener('change', handler)
RNFetchBlob.android.getContentIntent('image/png').then((files) => {
console.log(files)
})
android.addCompleteDownload(options:AndroidDownloadOption):Promise
0.10.6
Using this function to add an existing file to Downloads
app.
options:AndroidDownloadOption
An object that for setting the title, description, mime, and notification of the item.
RNFetchBlob.android.addCompleteDownload({
title : 'test file of RNFB',
description : 'desc',
mime : 'image/png',
path : SomePath,
showNotification : true
})