From d8e19415e34c8862a14dae2b6a0a480a927aaaf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Old=C5=99ich=20Jedli=C4=8Dka?= Date: Sun, 23 Feb 2020 03:09:10 +0100 Subject: [PATCH] Fix runtime exception. (#738) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the callback the processing does not go in the main UI thread, so we need to switch there. Otherwise on Android this throws Android.Util.AndroidRuntimeException with detail “Only the original thread that created a view hierarchy can touch its views”. Discovered by trying to login with Duo as a two-factor login type. Signed-off-by: Oldřich Jedlička --- src/App/Pages/Accounts/TwoFactorPageViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App/Pages/Accounts/TwoFactorPageViewModel.cs b/src/App/Pages/Accounts/TwoFactorPageViewModel.cs index 2c917b020..e1d7affa1 100644 --- a/src/App/Pages/Accounts/TwoFactorPageViewModel.cs +++ b/src/App/Pages/Accounts/TwoFactorPageViewModel.cs @@ -208,7 +208,7 @@ namespace Bit.App.Pages _broadcasterService.Unsubscribe(nameof(TwoFactorPage)); var disableFavicon = await _storageService.GetAsync(Constants.DisableFaviconKey); await _stateService.SaveAsync(Constants.DisableFaviconKey, disableFavicon.GetValueOrDefault()); - Application.Current.MainPage = new TabsPage(); + Device.BeginInvokeOnMainThread(() => { Application.Current.MainPage = new TabsPage(); }); } catch(ApiException e) {