Mediaplugin: "Camera has stopped"

Created on 26 Jul 2019  路  6Comments  路  Source: jamesmontemagno/MediaPlugin

Hi guys. I've a device LG G7 Android 8.0.0 and I installed the version 4.0.1.5 and the error continue, when the user take a photo say: "Camera has stopped". Any idea what's happening?

var result = await _media.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { DefaultCamera = Plugin.Media.Abstractions.CameraDevice.Rear, Name = Guid.NewGuid() + imageExtension, SaveToAlbum = false, PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small }).ConfigureAwait(false);

_Originally posted by @fadaEntrepidus in https://github.com/jamesmontemagno/MediaPlugin/issues/586#issuecomment-515489797_

Most helpful comment

I can confirm the fix above from @tjagdaledminc worked for us. @jamesmontemagno Is it possible to get this change reviewed for inclusion into a forthcoming release?

Thanks everyone

All 6 comments

We had to install another camera app while it appears another solution

Removing the LaunchMode = LaunchMode.SingleTask from MainActivity worked for me.
[Activity(Label = "MainActivity", Theme = "@style/MainTheme", ScreenOrientation = ScreenOrientation.Portrait)]

Removing the LaunchMode = LaunchMode.SingleTask from MainActivity worked for me.
[Activity(Label = "MainActivity", Theme = "@style/MainTheme", ScreenOrientation = ScreenOrientation.Portrait)]

I do not have that options and still crash

image

Use following code:

Uri photoURI;
// N is for Nougat Api 24 Android 7
if (Build.VERSION_CODES.N <= Android.OS.Build.VERSION.SdkInt)
{
// FileProvider required for Android 7. Sending a file URI throws exception.
photoURI = FileProvider.GetUriForFile(this,
Application.Context.PackageName + ".fileprovider",
new Java.IO.File(path.Path));
}
else
{
// For older devices:
// Samsung Galaxy Tab 7" 2 (Samsung GT-P3113 Android 4.2.2, API 17)
// Samsung S3
photoURI = Uri.FromFile(new Java.IO.File(path.Path));
}

I can confirm the fix above from @tjagdaledminc worked for us. @jamesmontemagno Is it possible to get this change reviewed for inclusion into a forthcoming release?

Thanks everyone

@tjagdaledminc && @cunnpole, I'm having the same issue. Where should I add the code proposed by @tjagdaledminc ?

I'm using Xamarin.Forms by the way.

Thanks in advance!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manonaga2188 picture manonaga2188  路  5Comments

Philyorkshire picture Philyorkshire  路  7Comments

Soumya-G picture Soumya-G  路  5Comments

irinakush picture irinakush  路  6Comments

Furqanali30 picture Furqanali30  路  7Comments