I'm trying to install an apk after I downloaded it.
Download works fine but when I try to install the package it does absolutely nothing.
There are no log messages and I have no clue what the my error might be.
Here is the code I use to launch the intent (it definitely gets executed):
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Uri contentUri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", apkFile);
Intent install = new Intent(Intent.ACTION_INSTALL_PACKAGE);
install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
install.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
install.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true);
install.addCategory(Intent.CATEGORY_DEFAULT);
install.setDataAndType(contentUri, "application/vnd.android.package-archive");
context.startActivity(install);
} else {
Intent install = new Intent(Intent.ACTION_INSTALL_PACKAGE);
install.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
install.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
context.startActivity(install);
}
I've checked the variables:
Any tips on what I could try are greatly appreciated.
Nevermind I made a typo in my AndroidManifest.xml.
How it was:
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES " />
How it should be:
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
Notice that one space at the end?
Took me 3 days to find it...