Closed smalgin closed 2 years ago
1) What value does CheckCapturePhotoSuppor
method return?
2) Can you show your android manifest file?
3) Can you provide more information? LogCat or behavior on other devices on your app
I had the same issue on Android. Looks like it happens when the app was built with the target of API level 30 in AndroidManifest.xml. It was ok with API level 29.
CheckCapturePhotoSupport returns false in this issue. If I ignore CheckCapturePhotoSupport() and proceed the app will crash.
@joeykang hi. Can you send me your AndroidManifest.xml?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" package="com.myapp.mobile" android:installLocation="auto" android:versionName="2.1.2">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="30" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<application android:label="MyApp">
<provider android:name="android.support.v4.content.FileProvider" android:authorities="com.myapp.mobile.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
</provider>
<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="myapp_general" />
<service android:name="com.myapp.mobile.LocalFirebaseMessagingService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
@joeykang You should configure your AndroidManifest.xml as described in Readme
@joeykang You should configure your AndroidManifest.xml as described in Readme
Comparing my AndroidManifest.xml with the one in README, a setting below was missing in my AndroidManifest.xml
<uses-feature android:name="android.hardware.camera" android:required="true" />
I added it in my AndroidManifest.xml but no luck with that on Google Pixel 3a and Android 30 emulator.
@joeykang it is also mandatory
<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>
@dimonovdd it worked ok with what you mentioned. There was my misunderstanding of configurations for Android. I appreciate your quick response.
@joeykang it is also mandatory
<queries> <intent> <action android:name="android.media.action.IMAGE_CAPTURE" /> </intent> </queries>
@smalgin Have you tried it? Can I close the issue? @joeykang I'm glad. Next time you should be more attentive to a little things😉
I'll try in a couple days. Too busy with the day's work.
In emulator: Did everything as prescribed, still Google Drive won't let me pick any files. Tried to cap from Emulated camera - img is captured but no mediafile at the exit. Then my Emulator froze. Resetting Emulator to factory defaults...
Ok, so look like it doesn't return from the pick/cap activity properly at all - bp placed after PickAsunc/CaptureAsync doesn't hit. I tried with the latest (2.0.0) the rest is the same as in bug description. I'll stick to X.Essentials for now & maybe try your plugin later when migrate to MAUI. Good luck and thanks!
Can you send me a small sample project? I would like to fix the bugs if there is one. But I can't reproduce it.
Currently 2.1.1 is the latest version of the plugin
I suspect that if I create empty Xamarin project w latest everything it might just work. I'll try, but ETA is unclear, sorry - too much stuff is happening around.
Hello @smalgin
I faced the same issue on iOS and the problem was that I wasn't asking for the permission to open the camera.
Something like that solve my issue:
`var status = await Permissions.CheckStatusAsync
if(status != PermissionStatus.Granted)
{
var request = await Permissions.RequestAsync
@Lukata Hi. Can you provide a sample?
I think you should change the function of getting a controller:
https://github.com/dimonovdd/Xamarin.MediaGallery#ios-optional
Hi @dimonovdd,
I solved my issue with the code I sent in my previous message :)
I just answered to this topic because it might be related because on Android too I had this issue and the problem was that I was missing the permission request (MediaGallery doesn’t open if you don’t ask the permission, and by default the permission is not Denied but Unknown).
best regards,
Lucas.
Description
Camera app doesn't open on CapturePhotoAsync
Expected behavior
Should open the camera app. Xamarin.Essentials media picker works.
Code snippet
if (MediaGallery.CheckCapturePhotoSupport()) return;
Configuration