I'm starting up as shown below, but the main screen is not displayed correctly at the first startup (main screen → license confirmation screen).
App.xaml
public App() { try { InitializeComponent(); Device.SetFlags(new string[] { "RadioButton_Experimental" }); MainPage = new NavigationPage(new Menu()); } catch (Exception) { } }
Menu.xaml
public Menu() { InitializeComponent(); MacAdd = ""; MacAdd = DependencyService.Get<IDeviceService>().GetMacAddr(); CLic lic = new CLic(); bool b = lic.KeyCheckAsync(); if (b == false) { try { string kcd = lic.Get_KeyCode(); await PopupNavigation.Instance.PushAsync(new Lic(kcd)); } catch (Exception ex) { } } else { } }
Answers
I notice you
bool b = lic.KeyCheckAsync();
, According to the method's name, this is an aync method in the construtor, if you use aync method in the construtor, it will make problem.when the constructor completes, the instance is still being asynchronously initialized, and there isn’t an obvious way to determine when the asynchronous initialization has completed.
You methend get the white screen, it may be caused by it, due to I cannot reproduce this issue.
Please google: Async OOP 2: Constructors by Stephen Cleary, here are several solution about solving this issue.
https://blog.stephencleary.com/2013/01/async-oop-2-constructors.html
When I did it with a release build, it started normally, but when I created and installed the APK, the screen did not start normally.
Did you refer to this steps before you release your application?
https://docs.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/?tabs=windows
If so, when you generate the apk file like this steps