Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Android activity killed when taking pictures using MediaPlugin

I am trying to take a picture and send it to a server using MediaPlugin. However android kills my application when switches to the camera, is there any way i can prevent this.

this is my method:

async void OnCameraClicked(object sender, EventArgs e)
            await Plugin.Media.CrossMedia.Current.Initialize();

            var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions()
                //SaveToAlbum = true, 
                CompressionQuality = 92,
                PhotoSize = PhotoSize.Medium,

            if (photo != null)
                var expenseReg = (Expenses)BindingContext;
                using (var memoryStream = new MemoryStream())
                    expenseReg.Photo = memoryStream.ToArray();

                    //optional, display the photo
                    Photo.Source = ImageSource.FromStream(() => { return photo.GetStream(); });
                Photo.IsVisible = true;


  • seanydaseanyda GBMember ✭✭✭✭✭

    Have you followed all the instructions here on setting it up?

    If you do everything correctly, It will work.

  • pKorsholmpKorsholm Member

    The issue is that my application is not resumed after the camera closes it just returns to the android home screen.

  • acceleratoraccelerator NOMember ✭✭
    edited August 2018

    Check if you have enabled "Do not keep activities". MainActivity will get destroyed. Xamarin.Forms only uses one activity.

Sign In or Register to comment.