The sample works because it uses a old Xamarin Forms Version, using XF 5, the exception is throwed.
Another comment, the exception is throwed using Android target version to 11, if you set it to 10 or 9, it works fine.
<application android:label=" PDFXamarinSample.Android" android:requestLegacyExternalStorage="true"> |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE">
</uses-permission>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> |
if (Android.OS.Environment.IsExternalStorageEmulated)
{
root = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).AbsolutePath;
} |
This article needs updated to include
Karthikeyan and
Gowthamraj's fixes. It does not work for Xamarin.Forms 5.0.0.2196 and Android 11 without their suggestions. FileProvider, though mentioned in the article, also isn't shown in the code samples.
We will consider your request to update the documentation. We will let you know once the KB documentation got published with the requested changes.