summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Forms.cs
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2017-09-21 17:42:43 (GMT)
committerJason Smith <jason.smith@xamarin.com>2017-09-28 21:59:12 (GMT)
commit8ff07402ecdd3ebc8bde30942be48e4c95ed4a01 (patch)
tree3224d7a0b68607e0cd45e260f7381f279d9da9c2 /Xamarin.Forms.Platform.Android/Forms.cs
parent4382364030f2b54ab1a72f1b36aee98801cdc257 (diff)
downloadxamarin-forms-8ff07402ecdd3ebc8bde30942be48e4c95ed4a01.zip
xamarin-forms-8ff07402ecdd3ebc8bde30942be48e4c95ed4a01.tar.gz
xamarin-forms-8ff07402ecdd3ebc8bde30942be48e4c95ed4a01.tar.bz2
Prevent Flags/IsInitialized check from crashing Android app on restart (#1151)
* Prevent Android app crashes on configuration restarts when flags are set * Update UI test * Fix typos * Don't prevent FastRenderers flag from being set
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Forms.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Forms.cs9
1 files changed, 9 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Android/Forms.cs b/Xamarin.Forms.Platform.Android/Forms.cs
index b568dee..5d0b4c1 100644
--- a/Xamarin.Forms.Platform.Android/Forms.cs
+++ b/Xamarin.Forms.Platform.Android/Forms.cs
@@ -34,6 +34,7 @@ namespace Xamarin.Forms
public static Context Context { get; internal set; }
public static bool IsInitialized { get; private set; }
+ static bool FlagsSet { get; set; }
internal static bool IsLollipopOrNewer
{
@@ -156,12 +157,20 @@ namespace Xamarin.Forms
public static void SetFlags(params string[] flags)
{
+ if (FlagsSet)
+ {
+ // Don't try to set the flags again if they've already been set
+ // (e.g., during a configuration change where OnCreate runs again)
+ return;
+ }
+
if (IsInitialized)
{
throw new InvalidOperationException($"{nameof(SetFlags)} must be called before {nameof(Init)}");
}
s_flags = flags.ToList().AsReadOnly();
+ FlagsSet = true;
}
static Color GetAccentColor()