title: java.lang.RuntimeException: Failure delivering result ResultInfo requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermissio
body: <p>I am following one tutorial upload video from android to server on this <a href="https://www.simplifiedcoding.net/android-upload-video-to-server-using-php/" rel="nofollow noreferrer">link</a> . But when i execute this activity it gave me run time exception. According to the exception I have added permissions in the <code>manifest</code> file. But still getting the error. Here is my activity file<br></p>
  
  <pre><code>public class UploadActivity extends AppCompatActivity implements View.OnClickListener {
      private Button buttonChoose;
      private Button buttonUpload;
      private TextView textView;
      private TextView textViewResponse;
      private static final int SELECT_VIDEO = 3;
      private String selectedPath;
      public void onCreate(Bundle savedInstanceState){
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_upload);
          report = getIntent().getStringExtra("report");
          buttonChoose = (Button) findViewById(R.id.buttonChoose);
          buttonUpload = (Button) findViewById(R.id.buttonUpload);
          textView = (TextView) findViewById(R.id.textView);
          textViewResponse = (TextView) findViewById(R.id.textViewResponse);
          buttonChoose.setOnClickListener(this);
          buttonUpload.setOnClickListener(this);
      }
      private void chooseVideo() {
          Intent intent = new Intent();
          intent.setType("video/*");
          intent.setAction(Intent.ACTION_GET_CONTENT);
          startActivityForResult(Intent.createChooser(intent, "Select a Video "), SELECT_VIDEO);
      }
      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          if (resultCode == RESULT_OK) {
              if (requestCode == SELECT_VIDEO) {
                  System.out.println("SELECT_VIDEO");
                  Uri selectedImageUri = data.getData();
                  selectedPath = getPath(selectedImageUri);
                  textView.setText(selectedPath);
              }
          }
      }
      public String getPath(Uri uri) {
          Cursor cursor = getContentResolver().query(uri, null, null, null, null);
          cursor.moveToFirst();
          String document_id = cursor.getString(0);
          document_id = document_id.substring(document_id.lastIndexOf(":") + 1);
          cursor.close();
          cursor = getContentResolver().query(
                  android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                  null, MediaStore.Images.Media._ID + " = ? ", new String[]{document_id}, null);
          cursor.moveToFirst();
          String path = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DATA));
          cursor.close();
          return path;
      }
  
      private void uploadVideo() {
          class UploadVideo extends AsyncTask&lt;Void, Void, String&gt; {
              ProgressDialog uploading;
              @Override
              protected void onPreExecute() {
                  super.onPreExecute();
                  uploading = ProgressDialog.show(UploadActivity.this, "Uploading File", "Please wait...", false, false);
              }
              @Override
              protected void onPostExecute(String s) {
                  super.onPostExecute(s);
                  uploading.dismiss();
                  textViewResponse.setText(Html.fromHtml("&lt;b&gt;Uploaded at &lt;a href='" + s + "'&gt;" + s + "&lt;/a&gt;&lt;/b&gt;"));
                  textViewResponse.setMovementMethod(LinkMovementMethod.getInstance());
              }
  
              @Override
              protected String doInBackground(Void... params) {
                  UploadFile u = new UploadFile();
                  String msg = u.uploadVideo(selectedPath);
                  return msg;
              }
          }
          UploadVideo uv = new UploadVideo();
          uv.execute();
      }
  
      @Override
      public void onClick(View v) {
          if (v == buttonChoose) {
              chooseVideo();
          }
          if (v == buttonUpload) {
              uploadVideo();
          }
      }
  }
  </code></pre>
  
  <p>Here is the logcat<br></p>
  
  <pre><code>03-16 09:00:28.658 5832-5832/com.example.luke.upload E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.luke.upload, PID: 5832
  java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=3, result=-1, data=Intent { dat=content://com.android.providers.media.documents/document/video:21079 flg=0x1 }} to activity {com.example.luke.upload/com.example.luke.upload.UploadActivity}: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/video/media from pid=5832, uid=10234 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
  at android.app.ActivityThread.deliverResults(ActivityThread.java:4998)
  at android.app.ActivityThread.handleSendResult(ActivityThread.java:5041)
  at android.app.ActivityThread.access$1600(ActivityThread.java:229)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1875)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:148)
  at android.app.ActivityThread.main(ActivityThread.java:7325)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
  Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/video/media from pid=5832, uid=10234 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
  at android.os.Parcel.readException(Parcel.java:1620)
  at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
  at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
  at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
  at android.content.ContentResolver.query(ContentResolver.java:502)
  at android.content.ContentResolver.query(ContentResolver.java:445)
  at com.example.luke.upload.UploadActivity.getPath(UploadActivity.java:63)
  at com.example.luke.upload.UploadActivity.onActivityResult(UploadActivity.java:52)
  at android.app.Activity.dispatchActivityResult(Activity.java:7165)
  at android.app.ActivityThread.deliverResults(ActivityThread.java:4994)
  at android.app.ActivityThread.handleSendResult(ActivityThread.java:5041) 
  at android.app.ActivityThread.access$1600(ActivityThread.java:229) 
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1875) 
  at android.os.Handler.dispatchMessage(Handler.java:102) 
  at android.os.Looper.loop(Looper.java:148) 
  at android.app.ActivityThread.main(ActivityThread.java:7325) 
  at java.lang.reflect.Method.invoke(Native Method) 
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
  </code></pre>
  
  <p>I am testing it on marshmallow<br>
  Thank you.</p>