From a077944629c4bdea31ef9542e8f81708982d635a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 27 Aug 2016 15:00:12 -0400 Subject: [PATCH] Cannot make OnCreate method async or things don't execute in correct order --- src/Android/MainActivity.cs | 4 ++-- src/Android/MainApplication.cs | 4 ++-- src/App/App.cs | 3 --- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index 6b54be372..4079965c4 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -25,7 +25,7 @@ namespace Bit.Android { private const string HockeyAppId = "d3834185b4a643479047b86c65293d42"; - protected async override void OnCreate(Bundle bundle) + protected override void OnCreate(Bundle bundle) { ToolbarResource = Resource.Layout.toolbar; TabLayoutResource = Resource.Layout.tabs; @@ -34,7 +34,7 @@ namespace Bit.Android // workaround for app compat bug // ref https://forums.xamarin.com/discussion/62414/app-resuming-results-in-crash-with-formsappcompatactivity - await Task.Delay(10); + Task.Delay(10).Wait(); Console.WriteLine("A OnCreate"); Window.SetSoftInputMode(SoftInput.StateHidden); diff --git a/src/Android/MainApplication.cs b/src/Android/MainApplication.cs index 774edae84..7f5ebc40a 100644 --- a/src/Android/MainApplication.cs +++ b/src/Android/MainApplication.cs @@ -43,13 +43,13 @@ namespace Bit.Android } } - public async override void OnCreate() + public override void OnCreate() { base.OnCreate(); // workaround for app compat bug // ref https://forums.xamarin.com/discussion/62414/app-resuming-results-in-crash-with-formsappcompatactivity - await Task.Delay(10); + Task.Delay(10).Wait(); RegisterActivityLifecycleCallbacks(this); AppContext = ApplicationContext; diff --git a/src/App/App.cs b/src/App/App.cs index 1c7568500..de5cad9d1 100644 --- a/src/App/App.cs +++ b/src/App/App.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using Bit.App.Abstractions; using Bit.App.Pages; using Xamarin.Forms; @@ -13,7 +11,6 @@ using Bit.App.Controls; using Plugin.Connectivity.Abstractions; using System.Net; using Acr.UserDialogs; -using PushNotification.Plugin.Abstractions; using XLabs.Ioc; namespace Bit.App