Hello,
According to the community's security rules, demos in external links cannot be downloaded.
According to the code you provided, this issue is caused by recreating the MainActivity
when calling the resume method when restoring the app from the background.
In fact, when creating SplashScreen, you can achieve this requirement with just one file from MainActivity.
Please refer to the following code sample.
[Activity(Label = "Mobile App",
Theme = "@style/Your_Splash_Theme",
Icon = "@drawable/Your_Icon",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
LaunchMode = LaunchMode.SingleTop)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.Window.RequestFeature(WindowFeatures.ActionBar);
// Name of the MainActivity theme you had there before.
base.SetTheme(Resource.Style.MainTheme);
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
// other methods
}
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.