示例#1
0
        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);
            }
        }
示例#2
0
        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"));
            };
        }
示例#3
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     AppLocation.StopLocationService();
 }
示例#4
0
 static AppLocation()
 {
     Current = new AppLocation();
 }