error when taking photo use xam.plug.media

am using the plugin to take a photo and save it on the device, but at the moment of taking the photo, it sends me the following one
I hope you can help me..

Java.Lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

public foto()
{
InitializeComponent();
takePhoto.Clicked += async (sender, args) =>
{

            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                await DisplayAlert("No Camera", ":( No camera avaialble.", "OK");
                return;
            }

            var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions 
            {
                //Directory = "Test",
               // Directory = "Test",
                Name = "prueba.jpg",
                SaveToAlbum = true,
                CompressionQuality = 75,
                CustomPhotoSize = 50,
                PhotoSize = PhotoSize.Medium,
                MaxWidthHeight = 100,
                DefaultCamera = CameraDevice.Front


            });

            if (file == null)
                return;

            //await DisplayAlert("Imagen Guarda", file.Path, "OK");

            using (var memoryStream = new MemoryStream())
            {

                byte[] ImageDat;
                //Bitmap resizedImage = Bitmap.CreateScaledBitmap(file, (int)width, (int)height, false);
                file.GetStream().CopyTo(memoryStream);
                ImageDat = memoryStream.ToArray();

                byte[] resizedImage =  ImageResizer.ResizeImageAndroid(ImageDat, 400, 400);

                //this.image.Source = ImageSource.FromStream(() => new MemoryStream(resizedImage));

                await DisplayAlert("Imagen Guarda", file.Path, "OK");
            }
        };

Best Answer

Answers

Sign In or Register to comment.