Rn-fetch-blob: android install apk

Created on 10 Sep 2018  ·  19Comments  ·  Source: joltup/rn-fetch-blob

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', https://api.7q.cn:54015/up/20180907/74635b50da8bc30fce200ea053616c7b2cf64ffaed30309b803149c394628f1d.apk)
.then((res) => {
android.actionViewIntent(res.path(), 'application/vnd.android.package-archive')
})

not work. help me! android 7.0+

Most helpful comment

Android 8+ add permission
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

All 19 comments

Have you solved the problem? I am also writing to download apk, can you share something?

need add path like this

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,
path: RNFetchBlob.fs.dirs.DownloadDir + "/fjdiatect.apk" //add
}
})
.fetch('GET', https://api.7q.cn:54015/up/20180907/74635b50da8bc30fce200ea053616c7b2cf64ffaed30309b803149c394628f1d.apk)
.then((res) => {
android.actionViewIntent(res.path(), 'application/vnd.android.package-archive')
})

Do you know how to get the download progress?

.progress((received: any, total: any) => {
console.log( Math.floor(received / total * 100) + '%')
})
It doesn't work

@meiqi1992
我安装上面的代码更改了还是报错,download manager could not resolve downloaded file path,
而且我打印了res的数据,路径不是在path中啊,

screenshot_2018-10-19-11-27-12

@Jeijie 你的代码贴出来看下?

RNFetchBlob.config({
addAndroidDownloads: {
useDownloadManager: true,
title: "xxx.apk",
description: "downloading...",
mime: "application/vnd.android.package-archive",
mediaScannable: true,
notification: true,
path: RNFetchBlob.fs.dirs.DownloadDir + "/xxx.apk"
}
})
.fetch("GET", appUrl)
.then(res => {
console.warn("res...", res,res.path());
android.actionViewIntent(
res.path(),
"application/vnd.android.package-archive"
);
});
};

现在是报另一个错
screenshot_2018-10-19-12-00-24

这个是权限问题,你看下android 还有什么权限没加

Android 8+ add permission
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

@TaumuLu , I test in Android 7.1.1,It no works.

这个是权限问题,你看下android 还有什么权限没加

某些机型 安装会白屏 啥问题

me too, help

this problem had soultion ? i have a same problem

i have a same problem

android.actionViewIntent(res.path(), 'application/vnd.android.package-archive')
how to soultion this problem ?

Hey , I don't know if it's related to this issue or not , but I downloaded the apk (higher version of the app) but when I want to install it from within the app it raise error " app not installed " but when I click on the downloaded apkon the top bar dowload-manager the app will be installed without any error ....
If someone can help me ,I'd appreaciate, I really need to install and update the app from within

I changed
compileSdkVersion = 28
targetSdkVersion = 28
,it workd。
but if
compileSdkVersion = 29
targetSdkVersion = 29
, it must turn on ACTION_MANAGE_UNKNOWN_APP_SOURCES,hope help someone

Hey , I don't know if it's related to this issue or not , but I downloaded the apk (higher version of the app) but when I want to install it from within the app it raise error " app not installed " but when I click on the downloaded apkon the top bar dowload-manager the app will be installed without any error ....
If someone can help me ,I'd appreaciate, I really need to install and update the app from within

Did you find a solution to the "not installed" problem?

Was this page helpful?
0 / 5 - 0 ratings