How to Multiple take picture using crossmedia

Viewed 193

How to Multiple take picture using Crossmedia, I use this it works perfectly but it will navigate again and again but i don't want this

bool isCamera = true;
while (isCamera)
{
file = await MediaPicker.TakePhotoAsync(new StoreCameraMediaOptions { SaveToAlbum = true, Name = "", Directory = "" });
if (file != null)
{
//save code}
else{
isCamera=false;
}
1 Answers

The plugin doesn't support multiple select . So we need to use dependency service for each platform to implement it.

To pick media from gallery yourself. Check this Tutorial.

For Android

public void OpenGallery()
{
    try
    {
        var imageIntent = new Intent(Intent.ActionPick);
        imageIntent.SetType("image/*");
        imageIntent.PutExtra(Intent.ExtraAllowMultiple, true);
        imageIntent.SetAction(Intent.ActionGetContent);
        ((Activity)Forms.Context).StartActivityForResult(Intent.CreateChooser(imageIntent, "Select photo"), OPENGALLERYCODE);
        Toast.MakeText(Xamarin.Forms.Forms.Context, "Tap and hold to select multiple photos.", ToastLength.Short).Show();
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.ToString());
        Toast.MakeText(Xamarin.Forms.Forms.Context, "Error. Can not continue, try again.", ToastLength.Long).Show();
    }
}

For iOS , you could use the plugin https://github.com/roycornelissen/GMImagePicker.Xamarin

Related