code: private void requestCameraPermission() {
          Log.w("BARCODE-SCANNER", "Camera permission is not granted. Requesting permission");
  
          final String[] permissions = new String[]{Manifest.permission.CAMERA};
  
          if (!shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) {
              requestPermissions(permissions, RC_HANDLE_CAMERA_PERM);
              return;
          }
  
          Snackbar.make(mGraphicOverlay, R.string.permission_camera_rationale, Snackbar.LENGTH_INDEFINITE)
                  .setAction(R.string.ok, new View.OnClickListener() {
                      @Override
                      public void onClick(View view) {
                          requestPermissions(permissions, RC_HANDLE_CAMERA_PERM);
                      }
                  })
                  .show();
  
  
          /*
          new AlertDialog.Builder(getContext())
                  .setTitle(R.string.perm_required)
                  .setMessage(R.string.permission_camera_rationale)
                  .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialogInterface, int i) {
                          //dialogInterface.dismiss();
                          requestPermissions(permissions, RC_HANDLE_CAMERA_PERM);
                      }
                  })
                  .setCancelable(false)
                  .show();*/
      }
docs: Handles the requesting of the camera permission.  This includes
  showing a "Snackbar" message of why the permission is needed then
  sending the request.