code: @Override
      public void onRequestPermissionsResult(int requestCode,
                                             @NonNull String[] permissions,
                                             @NonNull int[] grantResults) {
          if (requestCode != RC_HANDLE_CAMERA_PERM) {
              Log.d("BARCODE-SCANNER", "Got unexpected permission result: " + requestCode);
              super.onRequestPermissionsResult(requestCode, permissions, grantResults);
              return;
          }
  
          if (grantResults.length != 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
              Log.d("BARCODE-SCANNER", "Camera permission granted - initialize the camera source");
              // we have permission, so create the camerasource
              initiateCamera();
  
              return;
          }
  
          Log.e("BARCODE-SCANNER", "Permission not granted: results len = " + grantResults.length +
                  " Result code = " + (grantResults.length > 0 ? grantResults[0] : "(empty)"));
  
          if (mListener != null) mListener.onBarcodeScanningFailed("Camera permission denied");
          else {
              DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                      getActivity().finish();
                  }
              };
  
              AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
              builder.setTitle("Camera Permission Denied")
                      .setMessage(R.string.no_camera_permission)
                      .setPositiveButton(R.string.ok, listener)
                      .show();
          }
      }
docs: 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.
  </p>
  
  @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)