@Override
 public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
     super.onRequestPermissionsResult(requestCode, permissions, grantResults);
     if(requestCode == ACCESS_FINE_LOCATION_REQUEST_CODE)
     {
         if(grantResults[0] == PackageManager.PERMISSION_GRANTED)
         {
             onConnected(null);
         }
     }
 }
Example #2
0
  @Override
  public void onRequestPermissionsResult(
      int requestCode, String[] permissions, int[] grantResults) {

    PermissionsHelper.onRequestPermissionsResult(
        granted -> showContacts(), expectedCode, requestCode, permissions, grantResults);

    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  }
Example #3
0
 public void onRequestPermissionsResult(
     int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
   super.onRequestPermissionsResult(requestCode, permissions, grantResults);
   switch (requestCode) {
     case PERMISSIONS_REQUEST_ALL_PERMISSIONS:
       pager.setCurrentItem(pager.getCurrentItem() + 1);
       break;
     default:
       Log.e(TAG, "Unexpected request code");
   }
 }
Example #4
0
  @Override
  public void onRequestPermissionsResult(
      int requestCode, String[] permissions, int[] grantResults) {
    if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
      Log.i("1", "允许");
      // permission was granted, yay! Do the
      // contacts-related task you need to do.

    } else {
      Log.i("1", "拒绝");
      // permission denied, boo! Disable the
      // functionality that depends on this permission.
    }
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  }
 @Override
 public void onRequestPermissionsResult(
     int requestCode, String[] permissions, int[] grantResults) {
   switch (requestCode) {
     case REQUEST_CODE_ASK_PERMISSIONS:
       if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
         // Permission Granted
         initNextFlight();
       } else {
         // Permission Denied
         Toast.makeText(NextFlightActivity.this, "WRITE_CONTACTS Denied", Toast.LENGTH_SHORT)
             .show();
       }
       break;
     default:
       super.onRequestPermissionsResult(requestCode, permissions, grantResults);
   }
 }
 @Override
 public void onRequestPermissionsResult(
     final int requestCode, final String[] permissions, final int[] grantResults) {
   super.onRequestPermissionsResult(requestCode, permissions, grantResults);
   switch (requestCode) {
     case PERMISSION_REQ:
       {
         if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
           // We have been granted the Manifest.permission.WRITE_EXTERNAL_STORAGE permission. Now
           // we may proceed with exporting.
           FileHelper.createSamples(this);
         } else {
           Toast.makeText(this, R.string.no_required_permission, Toast.LENGTH_SHORT).show();
         }
         break;
       }
   }
 }
 @Override
 public void onRequestPermissionsResult(
     int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
   super.onRequestPermissionsResult(requestCode, permissions, grantResults);
   if (requestCode == REQUEST_CODE) {
     boolean bothGranted = true;
     for (int i = 0; i < permissions.length; i++) {
       if (Manifest.permission.RECORD_AUDIO.equals(permissions[i])
           || Manifest.permission.MODIFY_AUDIO_SETTINGS.equals(permissions[i])) {
         bothGranted &= grantResults[i] == PackageManager.PERMISSION_GRANTED;
       }
     }
     if (bothGranted) {
       shouldOpenFragment = true;
     } else {
       permissionsNotGranted();
     }
   }
 }
  /**
   * Callback for the result from requesting permissions. This method is invoked for every call on
   * {@link #requestPermissions(String[], int)}.
   *
   * <p><strong>Note:</strong> It is possible that the permissions request interaction with the user
   * is interrupted. In this case you will receive empty permissions and results arrays which should
   * be treated as a cancellation.
   *
   * @param requestCode The request code passed in {@link #requestPermissions(String[], int)}.
   * @param permissions The requested permissions. Never null.
   * @param grantResults The grant results for the corresponding permissions which is either {@link
   *     PackageManager#PERMISSION_GRANTED} or {@link PackageManager#PERMISSION_DENIED}. Never null.
   * @see #requestPermissions(String[], int)
   */
  @Override
  public void onRequestPermissionsResult(
      int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (requestCode != RC_HANDLE_CAMERA_PERM) {
      Log.d(TAG, "Got unexpected permission result: " + requestCode);
      super.onRequestPermissionsResult(requestCode, permissions, grantResults);
      return;
    }

    if (grantResults.length != 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
      Log.d(TAG, "Camera permission granted - initialize the camera source");
      // we have permission, so create the camerasource
      boolean autoFocus = getIntent().getBooleanExtra(AutoFocus, false);
      boolean useFlash = getIntent().getBooleanExtra(UseFlash, false);
      createCameraSource(autoFocus, useFlash);
      return;
    }

    Log.e(
        TAG,
        "Permission not granted: results len = "
            + grantResults.length
            + " Result code = "
            + (grantResults.length > 0 ? grantResults[0] : "(empty)"));

    DialogInterface.OnClickListener listener =
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            finish();
          }
        };

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder
        .setTitle("Multitracker sample")
        .setMessage(R.string.no_camera_permission)
        .setPositiveButton(R.string.ok, listener)
        .show();
  }
  /**
   * Callback for the result from requesting permissions. This method is invoked for every call on
   * {@link #requestPermissions(String[], int)}.
   *
   * <p><strong>Note:</strong> It is possible that the permissions request interaction with the user
   * is interrupted. In this case you will receive empty permissions and results arrays which should
   * be treated as a cancellation.
   *
   * @param requestCode The request code passed in {@link #requestPermissions(String[], int)}.
   * @param permissions The requested permissions. Never null.
   * @param grantResults The grant results for the corresponding permissions which is either {@link
   *     PackageManager#PERMISSION_GRANTED} or {@link PackageManager#PERMISSION_DENIED}. Never null.
   * @see #requestPermissions(String[], int)
   */
  @Override
  public void onRequestPermissionsResult(
      int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (requestCode != RC_HANDLE_CAMERA_PERM) {
      Log.d(TAG, "Got unexpected permission result: " + requestCode);
      super.onRequestPermissionsResult(requestCode, permissions, grantResults);
      return;
    }

    if (grantResults.length != 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
      Log.d(TAG, "Camera permission granted - initialize the camera source");
      // we have permission, so create the camerasource
      createCameraSource();
      return;
    }

    Log.e(
        TAG,
        "Permission not granted: results len = "
            + grantResults.length
            + " Result code = "
            + (grantResults.length > 0 ? grantResults[0] : "(empty)"));

    DialogInterface.OnClickListener listener =
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            finish();
          }
        };

    Log.e(TAG, "Permission was not granted dialog prompt");
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder
        .setTitle("Permission Not Granted")
        .setMessage(R.string.no_camera_permission)
        .setPositiveButton(android.R.string.ok, listener)
        .show();
  }
 @Override
 public void onRequestPermissionsResult(
     int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
   super.onRequestPermissionsResult(requestCode, permissions, grantResults);
   if (requestCode == STORAGE_PERMISSION_RC) {
     if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
       mHandler.postDelayed(
           new Runnable() {
             @Override
             public void run() {
               findViewById(R.id.folder_chooser).performClick();
             }
           },
           1000);
     } else {
       Toast.makeText(
               this,
               "The folder chooser will not work without permission to read external storage.",
               Toast.LENGTH_LONG)
           .show();
     }
   }
 }