public App() { InitializeComponent(); //check if device is connected to internet //https://docs.microsoft.com/en-us/xamarin/essentials/connectivity?context=xamarin%2Fxamarin-forms&tabs=ios var current = Connectivity.NetworkAccess; if (current != NetworkAccess.Internet) { MainPage = new NoInternetPage(); return; } if (_localizationService == null) { _localizationService = LocatorViewModel.Resolve <ILocalizationService>(); } if (_customerService == null) { _customerService = LocatorViewModel.Resolve <ICustomerService>(); } CurrentCostumerSettings = new CustomerSettingModel(); _customerService.SetCurrentCustomer(true, true); _localizationService.CreateOrUpdateLocales(); InitApp(); }
protected override void OnResume() { if (!httpConnection.Connect()) { MainPage = new NoInternetPage(); // Http Connection was unsuccessful return; } MainPage = new HomePage(); // Http Connection successful, proceed to homepage }
protected override void OnStart() { httpConnection = new SimpliPassHttpConnection(); if (!httpConnection.Connect()) { MainPage = new NoInternetPage(); // Http Connection was unsuccessful return; } MainPage = new HomePage { BindingContext = new HomePageViewModel(httpConnection) }; // Http Connection successful, proceed to homepage }
public App() { AndroidSpecific.Application.SetWindowSoftInputModeAdjust(this, AndroidSpecific.WindowSoftInputModeAdjust.Resize); InitializeComponent(); CrossConnectivity.Current.ConnectivityChanged += (sender, args) => { if (args.IsConnected) { MainPage = new MainPage(); } else { MainPage = new NoInternetPage(); } }; MainPage = new MainPage(); }