public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults) { // Ist notwendig, da sonst der Scan bei XSing beim ersten Mal nicht funktioniert ZXing.Net.Mobile.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults); if (requestCode == RC_REQUEST_LOCATION_PERMISSION) { if (grantResults.Length == 1 && grantResults[0] == Permission.Granted) { _AppOptionen.Standort.ZugriffChanged(true); AppLocation.StartLocationService(); } else { _AppOptionen.Standort.ZugriffChanged(false); } } else { base.OnRequestPermissionsResult(requestCode, permissions, grantResults); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); ZXing.Net.Mobile.Forms.Android.Platform.Init(); _AppOptionen = new AppOptionen { ApiClientHandler = new CustomAndroidClientHandler() }; LoadApplication(new App(_AppOptionen)); AppLocation.Current.LocationServiceConnected += (sender, e) => { AppLocation.Current.LocationService.LocationChanged += _AppOptionen.Standort.StandortChange; AppLocation.Current.LocationService.ProviderEnabled += _AppOptionen.Standort.GpsEnabledChanged; }; _AppOptionen.Standort.StartService = () => { if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) == (int)Permission.Granted) { AppLocation.StartLocationService(); } else { RequestLocationPermission(); } }; _AppOptionen.Standort.StopService = () => { AppLocation.StopLocationService(); }; _AppOptionen.Standort.FuncIstGpsOn = () => { var gpsLoc = (LocationManager)GetSystemService(LocationService); return(gpsLoc.IsProviderEnabled("gps")); }; }
protected override void OnDestroy() { base.OnDestroy(); AppLocation.StopLocationService(); }
static AppLocation() { Current = new AppLocation(); }