Android crashes when tapping the home button when the splash screen is being shown

EnzoAEnzoA USMember ✭✭

Hi,
I'm developing a Xamarin forms app. In Android, I construct the App object (then used as a parameter in the LoadApplication method) in the splash activity's OnResume. I wanna do this asynchronously so that only once App has been instantiated I start the main activity. Like this:

protected async override void OnResume()
{
base.OnResume();
.
.
.
await Task.Run(() =>
{
app = new App();
});
.
.
.
var mainActivityIntent = new Intent(this, typeof(MainActivity));
.
.
.
StartActivity(mainActivityIntent);
}

The problem is that, when the splash screen is being shown, if I tap on the Android home button, the app is sent to background but, after a few seconds, it crashes popping up the message "Unfortunately, (...) has stopped".
In the application output I'm getting this error: "Fatal signal 6 (SIGABRT), code -6". I assume I'm handling that task in the wrong way and maybe the main thread remains blocked.
Does anyone have any suggestions? Regards.

Sign In or Register to comment.