Home > Software design >  Maui "The current Activity can not be detected. Ensure that you have called Init in your Activi
Maui "The current Activity can not be detected. Ensure that you have called Init in your Activi

Time:12-03

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
            });

CodePudding user response:

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.

  • Related