my app downloaded apk to downloads/apks/ dir. I trying to install it, but had this error.Can you help? I use fileProvider to get access to apk file. I have already tried all tags and a lot of path combination but it is not working anyway This is install method
if(requireContext().packageManager.canRequestPackageInstalls()) {
val intent = Intent(Intent.ACTION_VIEW).apply {
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
setDataAndType(
FileProvider.getUriForFile(
requireContext(),
BuildConfig.APP_ID + ".provider",
File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).absolutePath , "/apks/" + "apk.apk")
),
"application/vnd.android.package-archive"
)
}
startActivity(intent)
} else {
viewModel.perform(NewUpdateAppViewEvent.OnRequestPermission)
}
This is paths file
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="some"
path="Download/"/>
</paths>
this is manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<application android:theme="@style/Theme.Uralsib">
<provider
android:name=".domain.interactor.MyFileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<receiver android:name = ".presentation.DownloadCompleteReceiver" android:exported = "true">
<intent-filter>
<action android:name = "android.intent.action.DOWNLOAD_COMPLETE"/>
</intent-filter>
</receiver>
</application>
</manifest>
I trying to install apk