diff --git a/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs b/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs index 334fbb6d4..92dd31c26 100644 --- a/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs +++ b/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs @@ -55,6 +55,7 @@ namespace Xamarin.Forms.Platform.Android bool _renderersAdded; bool _activityCreated; + bool _needMainPageAssign; bool _powerSaveReceiverRegistered; PowerSaveModeBroadcastReceiver _powerSaveModeBroadcastReceiver; @@ -341,6 +342,13 @@ namespace Xamarin.Forms.Platform.Android _previousState = _currentState; _currentState = AndroidApplicationLifecycleState.OnResume; + if (_needMainPageAssign) + { + _needMainPageAssign = false; + + SetMainPage(); + } + if (!_powerSaveReceiverRegistered && Forms.IsLollipopOrNewer) { // Start listening for power save mode changes @@ -397,6 +405,12 @@ namespace Xamarin.Forms.Platform.Android // Activity in pause must not react to application changes if (_currentState >= AndroidApplicationLifecycleState.OnPause) { + // If the main page is set after the activity has been paused, delay it to resume step + if (args.PropertyName == nameof(_application.MainPage)) + { + _needMainPageAssign = true; + } + return; }