[Android] Refresh main page on activity resume if main page has been changed when activity was paused (#9257) fixes #9093 fixes #5236
This commit is contained in:
Родитель
06c41ad09a
Коммит
b04b5a1a1e
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче