Exemplo n.º 1
0
        public void ShowCamera(View view)
        {
            Log.Info(TAG, "Show camera button pressed. Checking permission.");

            // Check if the Camera permission is already available.
            if (PermissionUtil.HasSelfPermission(this, Manifest.Permission.Camera))
            {
                // Camera permissions is already available, show the camera preview.
                Log.Info(TAG, "CAMERA permission has already been granted. Displaying camera preview.");
                ShowCameraPreview();
            }
            else
            {
                // Camera permission has not been granted.
                Log.Info(TAG, "CAMERA permission has NOT been granted. Requesting permission.");

                // Provide an additional rationale to the user if the permission was not granted
                // and the user would benefit from additional context for the use of the permission.
                if (ShouldShowRequestPermissionRationale(Manifest.Permission.Camera))
                {
                    Log.Info(TAG, "Displaying camera permission rationale to provide additional context.");
                    Toast.MakeText(this, Resource.String.permission_camera_rationale, ToastLength.Short).Show();
                }

                // Request Camera permission.
                RequestPermissions(new string[] { Manifest.Permission.Camera }, REQUEST_CAMERA);
            }
        }
Exemplo n.º 2
0
        public void ShowContacts(View v)
        {
            Log.Info(TAG, "Show contacts button pressed. Checking permissions.");

            // Verify that all required contact permissions have been granted.
            if (PermissionUtil.HasSelfPermission(this, PERMISSIONS_CONTACT))
            {
                // Contact permissions have been granted. Show the contacts fragment.
                Log.Info(TAG, "Contact permissions have already been granted. Displaying contact details.");
                ShowContactDetails();
            }
            else
            {
                // Contacts permissions have not been granted.
                Log.Info(TAG, "Contact permissions has NOT been granted. Requesting permission.");

                // Provide an additional rationale to the user if the permission was not granted
                // and the user would benefit from additional context for the use of the permission.
                if (ShouldShowRequestPermissionRationale(Manifest.Permission.ReadContacts) ||
                    ShouldShowRequestPermissionRationale(Manifest.Permission.WriteContacts))
                {
                    Log.Info(TAG, "Displaying contacts permission rationale to provide additional context.");
                    Toast.MakeText(this, Resource.String.permission_contacts_rationale, ToastLength.Short).Show();
                }

                // Request Contact permission.
                RequestPermissions(PERMISSIONS_CONTACT, REQUEST_CONTACTS);
            }
        }
Exemplo n.º 3
0
        public void ShowContacts(View v)
        {
            Log.Info(TAG, "Show contacts button pressed. Checking permissions.");

            // Verify that all required contact permissions have been granted.
            if (PermissionUtil.HasSelfPermission(this, PERMISSIONS_CONTACT))
            {
                Log.Info(TAG, "Contact permissions have already been granted. Displaying contact details.");
                // Contact permissions have been granted. Show the contacts fragment.
                ShowContactDetails();
            }
            else
            {
                Log.Info(TAG, "Contact permissions has NOT been granted. Requesting permission.");
                // contact permissions has not been granted (read and write contacts). Request them.
                RequestPermissions(PERMISSIONS_CONTACT, REQUEST_CONTACTS);
            }
        }
Exemplo n.º 4
0
        public void ShowCamera(View view)
        {
            Log.Info(TAG, "Show camera button pressed. Checking permission.");

            // Check if the Camera permission is already available.
            if (PermissionUtil.HasSelfPermission(this, Manifest.Permission.Camera))
            {
                Log.Info(TAG, "CAMERA permission has already been granted. Displaying camera preview.");
                // Camera permissions is already available, show the camera preview.
                ShowCameraPreview();
            }
            else
            {
                Log.Info(TAG, "CAMERA permission has NOT been granted. Requesting permission.");
                // Camera permission has not been granted. Request it.
                RequestPermissions(new string[] { Manifest.Permission.Camera }, REQUEST_CAMERA);
            }
        }