title: Android exception permission denied even after granting permission?
body: <p>What am I doing wrong?
  I have tried googlign the problem, but people mostly say it is an issue with android Q, but I don't think my problem is that.</p>
  
  <p>AndroidManifest.xml:</p>
  
  <pre><code>&lt;manifest ...&gt;
  &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Java:</p>
  
  <pre><code>void takePhoto(){
  
      ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
              Manifest.permission.READ_EXTERNAL_STORAGE,
              Manifest.permission.CAMERA},2);
  
      Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
      if (intent.resolveActivity(getPackageManager()) != null)
      {
              File photoFile = createPhotoFile();
              if(photoFile != null){
                  pathToFile = photoFile.getAbsolutePath();
                  Uri photoURI = getUriForFile(this, this.getPackageName() + ".fileprovider", photoFile);
                  intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
                  startActivityForResult(intent, REQUEST_CAMERA);
              }
          }
  
  }
  
  private File createPhotoFile() {
      String name = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
      File storageDir = getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
      File image = null;
      try{
          image = File.createTempFile(name, ".jpg", storageDir);
      } catch(IOException e){
          Log.d("myLog", "Except: " + e.toString());
      }
      return image;
  }
  </code></pre>