void Init() { _filter = new IntentFilter(); _filter.AddAction("android.bluetooth.adapter.action.STATE_CHANGED"); _filter.AddAction("android.location.PROVIDERS_CHANGED"); AppDomain.CurrentDomain.UnhandledException += LogUtils.OnUnhandledException; AndroidEnvironment.UnhandledExceptionRaiser += OnUnhandledAndroidException; #if APPCENTER AppCenter.Start( Configuration.Conf.APPCENTER_DIAGNOSTICS_TOKEN, typeof(Analytics), typeof(Crashes)); #endif DroidDependencyInjectionConfig.Init(); Xamarin.Essentials.Platform.Init(this); Current.Init(this); LocalesService.Initialize(); new MigrationService().Migrate(); _permissionsBroadcastReceiver = new PermissionsBroadcastReceiver(); _flightModeBroadcastReceiver = new FlightModeHandlerBroadcastReceiver(); _backgroundNotificationBroadcastReceiver = new BackgroundNotificationBroadcastReceiver(); LogUtils.SendAllLogs(); if (PlayServicesVersionUtils.PlayServicesVersionNumberIsLargeEnough(PackageManager)) { BackgroundFetchScheduler.ScheduleBackgroundFetch(); } }
private async void StartGoogleAPI() { try { await _viewModel.StartENService(); bool isRunning = await _viewModel.IsRunning(); if (isRunning) { BackgroundFetchScheduler.ScheduleBackgroundFetch(); } if (await _viewModel.IsEnabled() && !await _viewModel.IsRunning() && await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI) == BluetoothState.OFF) { await _permissionUtils.HasPermissions(); // wait until BT state change will be completed await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI); } } finally { UpdateUI(); } }
private async void StartGoogleAPI() { try { await _viewModel.StartENService(); bool isRunning = await IsRunning(); if (isRunning) { BackgroundFetchScheduler.ScheduleBackgroundFetch(); } if (await _viewModel.IsEnabled() && !await IsRunning() && await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI) == BluetoothState.OFF) { if (!_permissionUtils.AreAllPermissionsGranted()) { PreventMultiplePermissionsDialogsForAction(_permissionUtils.HasPermissions); // wait until BT state change will be completed await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI); } } } finally { UpdateUI(); } _semaphoreSlim.Release(); }
private async void StartGoogleAPI() { try { CloseReminderNotifications(); await _viewModel.StartENService(); bool isRunning = await IsRunning(); if (isRunning) { BackgroundFetchScheduler.ScheduleBackgroundFetch(); } if (await _viewModel.IsEnabled() && !await IsRunning() && await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI) == BluetoothState.OFF) { if (!_permissionUtils.AreAllPermissionsGranted()) { PreventMultiplePermissionsDialogsForAction(_permissionUtils.HasPermissions); // wait until BT state change will be completed await BluetoothStateBroadcastReceiver.GetBluetoothState(UpdateUI); } } } finally { UpdateUI(); } //showing dialog for new user if (GetIsBackgroundActivityDialogShowEnableNewUser() && !CheckIsEnableBatteryOptimizations()) { ShowBackgroundActivityDialog(); DialogLastShownDate = SystemTime.Now().Date; } _semaphoreSlim.Release(); }