xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.53k stars 505 forks source link

[Bug] MediaPicker.CapturePhotoAsync() does nothing on OnePlus 7T Pro (popup camera) #2055

Open Tuytje opened 1 year ago

Tuytje commented 1 year ago

Description

Calling MediaPicker.CapturePhotoAsync() does nothing on a OnePlus 7T Pro (Android), not even an error message can be seen. It is one of the phones with a motorized camera. One expects the camera to pop out of its enclosing, but nothing happens. Not even an errormessage. The method returns with a 'null' value. In logcat I can see the following:
interaction: PackageSetting{f751fc1 com.tuyware.mycollections/10337} -> PackageSetting{4d18366 com.oneplus.camera/10175} BLOCKED

Steps to Reproduce

  1. Call MediaPicker.CapturePhotoAsync()

Expected Behavior

Camera to pop out, and be able to take a picture

Actual Behavior

The method returns immediatly with a 'null' value. Logcat gives the following: interaction: PackageSetting{f751fc1 com.tuyware.mycollections/10337} -> PackageSetting{4d18366 com.oneplus.camera/10175} BLOCKED The same code works on other devices

Basic Information

Tuytje commented 1 year ago

Anyone looking into this, or having a workaround?

irongut commented 1 year ago

@Tuytje I notice your device is running Android 13, are you also targetting Android 13 in your project?

There is an issue with Android 13 where the correct permissions are not requested by Xamarin Essentials and this makes the camera unusable if also targetting Android 13. It should request camera permissions then media permissions but does not request the media permissions. My workaround is to target Android 12.1 for now but I will need a proper fix by Nov 2023. See #2041.

Tuytje commented 1 year ago

Thank you for the suggestion. I have noticed the issue with the Android 13 target, so we are targetting Android 12.1. The camera works on all our test devices, except for the one with the popup camera. It just doesn't do anything, no error even.