Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

i need help with this error in plugin.media

$
0
0

only one operation can be active at a time xamarin

this is the code :

 public async void Agregar_Clicked(object sender, EventArgs e)
    {
        var cameraStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera);
        var storageStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage);

        if (cameraStatus != PermissionStatus.Granted || storageStatus != PermissionStatus.Granted)
        {
            var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Camera, Permission.Storage });
            cameraStatus = results[Permission.Camera];
            storageStatus = results[Permission.Storage];
        }

        if (cameraStatus == PermissionStatus.Granted && storageStatus == PermissionStatus.Granted)
        {
            var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
            {
                Directory = "Sample",
                Name = "test.jpg"
            });
        }
        else
        {
            await DisplayAlert("Permissions Denied", "Unable to take photos.", "OK");
        }

    }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>