diff options
Diffstat (limited to 'Xamarin.Forms.Platform.Android/AppCompat')
-rw-r--r-- | Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs b/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs index 6bd7df2b..b6736df2 100644 --- a/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs +++ b/Xamarin.Forms.Platform.Android/AppCompat/FormsAppCompatActivity.cs @@ -44,6 +44,9 @@ namespace Xamarin.Forms.Platform.Android int _statusBarHeight = -1; global::Android.Views.View _statusBarUnderlay; + // Override this if you want to handle the default Android behavior of restoring fragments on an application restart + protected virtual bool AllowFragmentRestore => false; + protected FormsAppCompatActivity() { _previousState = AndroidApplicationLifecycleState.Uninitialized; @@ -139,8 +142,17 @@ namespace Xamarin.Forms.Platform.Android callback(resultCode, data); } + protected override void OnCreate(Bundle savedInstanceState) { + if (!AllowFragmentRestore) + { + // Remove the automatically persisted fragment structure; we don't need them + // because we're rebuilding everything from scratch. This saves a bit of memory + // and prevents loading errors from child fragment managers + savedInstanceState?.Remove("android:support:fragments"); + } + base.OnCreate(savedInstanceState); AToolbar bar; |