Exemplo n.º 1
0
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
        {
            Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

            if (requestCode == LocationManagerDroid.LOCATION_REQUEST_CODE && grantResults[0] == Permission.Granted)
            {
                LocationManagerDroid.StartLocation();
            }

            base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            Xamarin.FormsGoogleMaps.Init(this, savedInstanceState);
            LocationManagerDroid.Init(this);

            LoadApplication(new App());
        }
Exemplo n.º 3
0
        public LocationManagerDroid()
        {
            if (sActive != null)
            {
                sLocationManager.RemoveUpdates(sActive);
            }
            sActive = this;

            if (ContextCompat.CheckSelfPermission(sContext, Manifest.Permission.AccessCoarseLocation) != (int)Permission.Granted)
            {
                ActivityCompat.RequestPermissions((Activity)sContext, new string[] { Manifest.Permission.AccessCoarseLocation }, LOCATION_REQUEST_CODE);
            }
            else
            {
                StartLocation();
            }
        }