I try programmatically to install the APK file. I put it into the "download" folder of the device. I make everything according to the instructions from this link Installing APK
i.e. I put the xml file in Resources/xml/provider_paths.xml
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path name="external_files" path="."/>
</paths>
I add the manifest inside application tags
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
And then I try to install APK in code
public void OpenApk()
{
var path =
Android.OS.Environment.GetExternalStoragePublicDirectory(
Android.OS.Environment.DirectoryDownloads);
Java.IO.File file = new Java.IO.File(path + "/", "test.apk");
Intent install = new Intent(Intent.ActionView);
Android.Net.Uri apkURI = FileProvider.GetUriForFile(Forms.Context, Forms.Context.ApplicationContext.PackageName + ".provider", file);
install.SetDataAndType(apkURI, "application/vnd.android.package-archive");
install.AddFlags(ActivityFlags.NewTask);
install.AddFlags(ActivityFlags.GrantReadUriPermission);
Forms.Context.StartActivity(install);
}
But the installation fails with "There was a problem parsing the package" What can be wrong?