Exemplo n.º 1
0
        /// <summary>
        /// Activity Life cycle method
        ///
        /// This is method is called automatically whenever the activity state is updated, usually after
        /// its creation.
        /// </summary>
        protected override void OnSaveInstanceState(Bundle outState)
        {
            setLatestAppState(outState);

            if (verifyLocationPermissions() && !AndroidController.hasInitialized())
            {
                initMaps();
                initControllersAndStartServices();

                // Clean initilization variables, set the state of the activity and register services.
                dismissPermissionsDialogs();
                AndroidController.setHasInitialized(true);

                OnResume();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Handles the runtime permissions.
 /// </summary>
 private bool verifyLocationPermissions()
 {
     if (AndroidController.hasGrantedLocationPermission())
     {
         return(true);
     }
     else if ((int)Build.VERSION.SdkInt < 23)
     {
         AndroidController.setHasGrantedLocationPermission(true);
         return(true);
     }
     else
     {
         getLocationPermissionAsync();
         return(false);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Activity Life cycle method
        ///
        /// This method receives the response of the permission dialogs that were presented to user.
        /// </summary>
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
        {
            switch (requestCode)
            {
            case mRequestLocationId: {
                if (grantResults[0] == Permission.Granted)
                {
                    AndroidController.setHasGrantedLocationPermission(true);
                    OnSaveInstanceState(getLatestAppState());
                }
                else
                {
                    showGiveLocationPermissionsDialog();
                }
            }

            break;
            }
        }
Exemplo n.º 4
0
        void getLocationPermissionAsync()
        {
            if ((int)Build.VERSION.SdkInt >= 23)
            {
                const string permission = Manifest.Permission.AccessFineLocation;

                if (CheckSelfPermission(permission) == (int)Permission.Granted)
                {
                    AndroidController.setHasGrantedLocationPermission(true);
                    OnSaveInstanceState(getLatestAppState());
                }
                else if (CheckSelfPermission(permission) == Permission.Denied ||
                         ShouldShowRequestPermissionRationale(permission))
                {
                    showGiveLocationPermissionsDialog();
                }
                else
                {
                    RequestPermissions(mPermissionsLocation, mRequestLocationId);
                }
            }
        }