Exemplo n.º 1
0
 public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
 {
     if (requestCode == REQUEST_ACCESS_FINE_LOCATION)
     {
         HasAccessFineLocation = (grantResults.Length == 1) && (grantResults[0] == Permission.Granted);
         AccessFineLocationPermissionUpdated?.Invoke(HasAccessFineLocation);
     }
     else if (requestCode == REQUEST_ACTIVITY_RECOGNITION)
     {
         HasActivityRecognition = (grantResults.Length == 1) && (grantResults[0] == Permission.Granted);
         ActivityRecognitionPermissionUpdated?.Invoke(HasActivityRecognition);
     }
 }
Exemplo n.º 2
0
        public void RequestActivityRecognition()
        {
            const string activityRecognition = Manifest.Permission.ActivityRecognition;

            HasActivityRecognition = ContextCompat.CheckSelfPermission(this, activityRecognition) == Permission.Granted;

            if (!HasActivityRecognition)
            {
                ActivityCompat.RequestPermissions(this, new string[] { activityRecognition }, REQUEST_ACTIVITY_RECOGNITION);
            }
            else
            {
                ActivityRecognitionPermissionUpdated?.Invoke(HasActivityRecognition);
            }
        }