-
Notifications
You must be signed in to change notification settings - Fork 500
Adds Granular media permissions for Android 13+ #2065
Conversation
Adds Granular media permissions for Android 13+ https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions
@microsoft-github-policy-service agree |
{ | ||
return new (string, bool)[] | ||
{ | ||
("android.permission.READ_MEDIA_IMAGES", true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will probably be needed to spit out into their own permissions.
My app only needs access to the users images, I don't want to add/request for 'Audio'/'Video' permissions when it's not needed
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29"/> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"/> | ||
<!--Android 13 specific media folders--> | ||
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" android:minSdkVersion="32"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
android:minSdkVersion for these READ_MEDIA_* permissions should be 33 since they were only added in Android API 33 (Android 13). See here: https://developer.android.com/reference/android/Manifest.permission#READ_MEDIA_AUDIO
</queries> | ||
<application android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/MainTheme"></application> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.xamarin.essentials" android:installLocation="auto"> | ||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the device tests to test features in Android API 33, the target version surely needs to be at least 33 here?
please merge |
Please merge this PR, our customers already complain a lot |
Any news on this? Our app is useless in Android 13 because of this bug. Please merge and publish as soon as possible. |
@simader @daflotsch you can easily implement this yourself by extending the current permissions as described in our documentation: https://learn.microsoft.com/xamarin/essentials/permissions?tabs=android#extending-permissions As mentioned in this PR also about permissions, Xamarin.Essentials is in maintanance only and we're not looking to add new functionality unless we absolutely have to. New development will happen in .NET MAUI. |
I was under the impression that when you guys said that Xamarin would support up to android 13 (even under maintenance), this kind of issue would still be addressed. |
I just have to deal with permission issues in a 5 years old Xamarin app. Also facing pressure for release as it has to support a new product. To my knowledge, Xamarin EOL date is currently May 1, 2024. Therefore, I do not understand statements like "Xamarin.Essentials is in maintanance only and we're not looking to add new functionality unless we absolutely have to.". This is not acceptable. We need running Xamarin products until this date. And if Android or iOS are making changes that break general usability, this is a "have to". I wonder if others see it the same way... |
/agree While they don't move, this is what you can do to make it work.
|
Hi @WanftMoon really thank you for your solution. In my case, i only had to do step 3 of your suggestion in order to ge tthis to work. I changed the OnRequestPermissionResult, and added the lines you suggested, and also updated my manifest - and it works. I did not have to implement a Interface (i think this is because my manifest already included the new permissions.
Manifest
|
Will this still work with a min SDK of <33 specified? Or do both min and target SDK have to be 33? And so should the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE entries in the manifest just stay as there are or be removed? Our min SDK is version 27 and so I'm wondering if we need to require users to go to 33... |
Yeah, it will. My mininum is 26 right now and target is 33. And you need those permissions to devices below 33. |
So your manifest simply has all these entries (without specifying "minSdkVersion" and "maxSdkVersion" attributes)?
|
yup
|
You are the man! Thanks. |
Adds Granular media permissions for Android 13+
https://developer.android.com/about/versions/13/behavior-changes-13#granular-media-permissions
Description of Change
Adds Granular media permissions for Android 13+
Starting from Android 13 you can no longer request STORAGE_READ, and STORAGE_WRITE permissions.
Instead, you have to ask for granular permissions:
READ_MEDIA_IMAGES
READ_MEDIA_VIDEO
READ_MEDIA_AUDIO
Bugs Fixed
Provide links to issues here. Ensure that a GitHub issue was created for your feature or bug fix before sending PR.
#2037
#2041
API Changes
None
Behavioral Changes
None
PR Checklist
main
at time of PR