I've got problem about intent in the Xamarin.Forms. I want to install downloaded APK file,which stored in the Internal Storage root. I have written code and it works perfectly on the Android 6 but it doesn't work on the Android 8 and 9. I used FileProvider class,I know that it's a way for Android 7+ in this case,but it still doesn't work.
no any error,it's opening packageInstaller and closing immediately,but when I tried absolutely same code in the new project,it works perfectly.
I checked,when file name is incorrect it's showing parsing error. also I checked that File.EXists method returns true with this APK file
I have no ideas,why happens it
tried update Xamarin.Forms NuGet
******MainActivity******
private void DetailPage_openit()
{
CrossPermissions.Current.RequestPermissionsAsync(Plugin.Permissions.Abstractions.Permission.Storage);
Intent intent = new Intent(Intent.ActionView);
intent.SetDataAndType(FileProvider.FileProvider.GetUriForFile(this, "aaaa", new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory + "/gcam14.apk")), "application/vnd.android.package-archive");
intent.SetFlags(ActivityFlags.NewTask);
intent.SetFlags(ActivityFlags.GrantReadUriPermission);
StartActivity(intent);
}
******AndroidManifest.xml******
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:targetSandboxVersion="1" android:versionCode="1" android:versionName="1.0" package="com.granturismo.gcamator" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="Gcamator" android:usesCleartextTraffic="true" android:icon="@drawable/logo" android:allowBackup="false">
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="aaaa"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
<uses-library android:name="org.apache.http.legacy" android:required="false" />
</application>
<uses-permission android:name="android:permission.REQUEST_INSTALL_PACKAGES"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
******provider_paths.xml******
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>