protected override void OnCreate(Bundle savedInstanceState) { if (savedInstanceState == null) { var prefs = PreferenceManager.GetDefaultSharedPreferences(this); AppCompatDelegate.DefaultNightMode = prefs.GetBoolean("NightMode", default) ? AppCompatDelegate.ModeNightYes : AppCompatDelegate.ModeNightNo; #warning fix on release int firstLaunch; try { firstLaunch = prefs.GetInt(PreferencesConstants.FirstLaunch, launchCode); } catch { firstLaunch = launchCode; } if (firstLaunch == launchCode) { prefs.Edit().Clear().Apply(); prefs.Edit().PutInt(PreferencesConstants.FirstLaunch, launchCode + 1).Apply(); } this.ScheduleVmPreloadTask = Task.Run(() => PrepareSchdeuleVm(prefs)); } SetTheme(Resource.Style.AppTheme_NoActionBar); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); Xamarin.Essentials.Platform.Init(this, savedInstanceState); if (this.loggerFactory == null) { this.loggerFactory = DependencyInjector.GetILoggerFactory(); } StringProvider.Context = this; AssetProvider.AssetManager = this.Assets; StringProvider.SetUpLogger(this.loggerFactory); if (savedInstanceState == null) { ChangeFragment(ScheduleView.NewInstance(this.ScheduleVmPreloadTask), true); //SplashView.ScheduleVmPreloadTask = null; } else { // TODO: Fix stack //ChangeFragment(this.SupportFragmentManager.GetBackStackEntryAt(0)., Fragments.ScheduleMain, false); } ActivityCompat.RequestPermissions(this, new string[] { Android.Manifest.Permission.Internet }, 123); this.logger = this.loggerFactory.Create <MainView>(); var navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); navigationView.NavigationItemSelected += (obj, arg) => OnNavigationItemSelected(arg.MenuItem); navigationView.SetCheckedItem(Resource.Id.nav_schedule); this.clickBackAgain = GetString(Resource.String.click_back_again); this.doubleBackToExitPressedOnce = false; PreferenceManager.GetDefaultSharedPreferences(this) .RegisterOnSharedPreferenceChangeListener(this); this.logger.Debug("MainActivity created successfully"); }