title: Android READ_EXTERNAL_STORAGE permission not working
body: <p>I'm trying to create a simple app that can get an image from the Gallery app and display it on an imageButton. I'm testing with API 21 on a phone running Android 5.0.1. Unfortunately, no matter what I try I keep getting a security error - even when I specify the permissions.</p>
  
  <p>My code for getting retrieving the image is:</p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent){
      super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
  
      switch(requestCode){
          case PICK_IMAGE_REQUEST:
              if(resultCode == RESULT_OK &amp;&amp; imageReturnedIntent != null &amp;&amp; imageReturnedIntent.getData() != null) {
                  Uri uri = imageReturnedIntent.getData();
                  try {
                      Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
                      // Log.d(TAG, String.valueOf(bitmap));
                      ImageButton ib = (ImageButton) findViewById(R.id.inputImg);
                      ib.setImageBitmap(bitmap);
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              break;
      }
  }
  </code></pre>
  
  <p>The code works when I try to select an image from Dropbox, but when I select an image from gallery, I get</p>
  
  <pre><code>java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media/35634 from pid=25240, uid=10070 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
  </code></pre>
  
  <p>I made the use-permission tag for READ_EXTERNAL_STORAGE a child of manifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  package="[REDACTED]"&gt;
  
      &lt;uses-sdk
      android:minSdkVersion="14"
      android:targetSdkVersion="23" /&gt;
  
      &lt;uses-permission tools:node="replace" android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="18" /&gt;
  
      &lt;application&gt;
          [REDACTED]
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>I've searched high and low on other posts, but still can't seem to figure out why I'm still getting this pesky error.</p>