Closed jarkkokoskinen closed 3 years ago
I think this is the incorrect method we are using. It should be EnsureGrantedAsync
:
await Permissions.EnsureGrantedAsync<Permissions.StorageRead>();
instead of RequestAsync
I think this will also happen in 3 places due to this same error:
Description
Recently I started to use Xamarin.Essentials FilePicker for picking files from the file system. When using the FilePicker on Android (Android 10) I noticed that the permission prompt for the storage read permission didn't work properly: When choosing "Deny" from the prompt the file system is still opened, even though it shouldn't. From reading the source code (https://github.com/xamarin/Essentials/blob/main/Xamarin.Essentials/FilePicker/FilePicker.android.cs) it seems that the permission is only asked, but nothing is done with the result (line 19): await Permissions.RequestAsync();.
Steps to Reproduce
Expected Behavior
File system doesn't open.
Actual Behavior
File system opens, even though it shouldn't have the right permission. User is still able to navigate the file system and pick files from it.
Basic Information
Workaround
I was able to create a workaround by prompting the permission alert myself before using the FilePicker class' PlatformPickAsync method by using the Xamarin.Essentials Permission class. This didn't prompt a second permission alert from the FilePicker class on Android 10/Samsung SM-G973F, so it fit for my need at the moment.