@Override
  public void onRequestPermissionsResult(int requestCode,
      String[] permissions,
      int[] grantResults) {
    if (requestCode != RC_HANDLE_CAMERA_PERM) {
      Log.e(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 camera source.
      createCameraSource();
      return;
    }

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

    // Permission is not granted.
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int id) {
        // If this activity is started from {@link AddAccountActivity}, open it again.
        if (mStartFromAddAccountActivity) {
          startActivity(new Intent(BarcodeCaptureActivity.this, AddAccountActivity.class));
        }
        finish();
      }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(R.string.no_camera_permission)
        .setPositiveButton(R.string.ok, listener)
        .show();
  }
Handles the requesting of the camera permission.  This includes showing a "Snackbar" message of
why the permission is needed then sending the request.
java/com/google/android/apps/authenticator/barcode/BarcodeCaptureActivity.java