Open rickclephas opened 3 years ago
it would be good, if we could add android:maxSdkVersion in our permission
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28"/>
I think this part of code will work
if(Android.OS.Build.VERSION.SdkInt <= Android.OS.BuildVersionCodes.P)
await EnsureGrantedAsync<Permissions.StorageWrite>();
...
if (Android.OS.Build.VERSION.SdkInt <= Android.OS.BuildVersionCodes.P)
capturePhotoIntent.AddFlags(ActivityFlags.GrantWriteUriPermission);
Description
The current implementation of
PlatformCaptureAsync
requires theWRITE_EXTERNAL_STORAGE
permission. This permission is only needed to write files outside application folders. Captured photos and videos are stored in the application cache folder which doesn't require any permission on API level 19 and above.I don't see any other reason why the
WRITE_EXTERNAL_STORAGE
permission should be required. In case this permission is required then the functionality would break on Android 11 since it doesn't provide additional access anymore: https://developer.android.com/about/versions/11/privacy/storage#permissions-target-11.Expected Behavior
The
WRITE_EXTERNAL_STORAGE
permission isn't required to capture a photo or video.Actual Behavior
Incase the
WRITE_EXTERNAL_STORAGE
permission isn't added to the app the following check fails: https://github.com/xamarin/Essentials/blob/7218ab88f7fbe00ec3379bd54e6c0ce35ffc0c22/Xamarin.Essentials/MediaPicker/MediaPicker.android.cs#L63