2

I am using Xam.Plugin.Media nuget package.

await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
            {
                SaveToAlbum = true,
                PhotoSize = PhotoSize.MaxWidthHeight,
                Name = fullFileName,
                DefaultCamera = CameraDevice.Rear,
                MaxWidthHeight = 1000,
                AllowCropping = false
            });
Arup
  • 155
  • 11
  • 1
    Why are you using a Xamarin plugin? MAUI has an integrated camera control. https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/device-media/picker?view=net-maui-7.0&tabs=android – Jason Dec 03 '22 at 13:37
  • I used MediaPicker first. But faced an issue to save a clicked photo to save to android directory even in app's cached directory, and used CrossMedia instead. – Arup Dec 03 '22 at 13:40
  • Is there any plugin for this ? – TechOverflow Dec 03 '22 at 15:13

1 Answers1

4

You can do one thing.

public class MainActivity : MauiAppCompatActivity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        base.OnCreate(savedInstanceState);
    }
}

just update this in MainActivity.cs under Platform>Android folder in MAUI. Mine has worked perfectly I hope you will find it useful too.

TechOverflow
  • 117
  • 9