In my .Net Maui application, I have to override the basic Android OnCreate method as follows :
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
ThemeChanged(AppCore.Instance.CurrentThemeDark());
MauiUtils.AndroidUtils.Permissions.GetInstance(this).GetPermissions(PermissionsGroupLocation);
}
My issue being, sometimes (but I actually have no clue of when or why) when I start my app to debug it using the Visual Studio emulator, I end up having an exception in this method : base.OnCreate(savedInstanceState)
raises **System.NullReferenceException:** 'Object reference not set to an instance of an object.'
.
I can confirm with a breakpoint that savedInstance
is actually null, however the base OnCreate
method accepts a Bundle?
as parameter, and my method in itself doesn’t use the savedInstance at all.
The only way I found to fix this is to completely reset the emulator, and I suppose it’s an emulator-related issue, but wanted to ask in case I was actually missing something.
3