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.

Camera problem in xamarin

Sometime i get error black screen ProjectName_Andrioid can log out when i take a picture with Camera using( CrossMedia.Current.TakePhotoAsync)
Is any way to solve.


  • LeonLuLeonLu Member, Xamarin Team Xamurai

    @TTW I wrote a demo about use this MediaPlugin, Here is running GIF.

    Using following code.

        async private void Button_Clicked(object sender, EventArgs e)
            await CrossMedia.Current.Initialize();
            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
                DisplayAlert("No Camera", ":( No camera available.", "OK");
            var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                Directory = "Sample",
                Name = "test.jpg"
            if (file == null)
            await DisplayAlert("File Location", file.Path, "OK");
            image.Source = ImageSource.FromStream(() =>
                var stream = file.GetStream();
                return stream;

    Here is layout.

             <Button Text="click" Clicked="Button_Clicked"/>
            <Image x:Name="image"/>

    Here is my demo.

Sign In or Register to comment.