title: Can't select any image from system image picker
body: <p>So I implemented code to let me pick images from my filesystem using the default image picker in Android, but for some reason every image is greyed out. It's not letting me choose an image at all. I tested it on Marshmallow 6.0.1 (from where screenshot is taken) and on Lollipop 5.1.1.</p>
  
  <p><a href="https://i.stack.imgur.com/zm3Nq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zm3Nq.jpg" alt="enter image description here"></a></p>
  
  <p>Here's my implementation:</p>
  
  <p>Manifest:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  &lt;uses-permission android:name="com.company.app.permission.C2D_MESSAGE" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  </code></pre>
  
  <p>Note that all of this has been done on the same activity, LaunchActivity.java</p>
  
  <p>Variables as used:</p>
  
  <pre><code>private ImageView picturebutton;
  private Bitmap imageBitmap;
  final private int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE=1;
  private int PICK_IMAGE_REQUEST = 1;
  </code></pre>
  
  <p>ImageView acting as button:</p>
  
  <pre><code>picturebutton = (ImageView) findViewById(R.id.chose_picture);
  View.OnClickListener picturebuttonClickListener = new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              checkStorageReadPermission(LaunchActivity.this);
          }
      };
      picturebutton.setOnClickListener(picturebuttonClickListener);
  </code></pre>
  
  <p>The method <em>checkStorageReadPermission()</em> which requests for storage access permission:</p>
  
  <pre><code>public void checkStorageReadPermission(final Context context){
      if(ContextCompat.checkSelfPermission(LaunchActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){
          if(ActivityCompat.shouldShowRequestPermissionRationale(LaunchActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE)){
          }
          else {
              ActivityCompat.requestPermissions(LaunchActivity.this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
          }
      }
      else{
          Log.d("Permissions","Permission was already granted");
          startActivity(openGallery());
      }
  }
  </code></pre>
  
  <p>The override code for <em>onRequestPermissionsResult()</em>:</p>
  
  <pre><code>@Override
  public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
      switch (requestCode) {
          case MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE:
              if (grantResults.length &gt; 0 &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                  startActivity(openGallery());
                  Log.d("Permissions","Can read storage");
              } else {
                  //code for deny
                  Log.e("Permissions","Can't read storage");
              }
              break;
      }
  }
  </code></pre>
  
  <p>The intent <em>openGallery()</em> which calls the image picker:</p>
  
  <pre><code>public Intent openGallery() {
          Intent og = new Intent();
          og.setType("image*/");
          og.setAction(Intent.ACTION_GET_CONTENT);
          startActivityForResult(Intent.createChooser(og,"Pick a picture"),PICK_IMAGE_REQUEST);
          return og;
      }
  </code></pre>
  
  <p>The code to override <em>onActivityResult()</em> when the Intent is called:</p>
  
  <pre><code>@Override
  public void onActivityResult(int requestCode, int resultCode, Intent data){
      super.onActivityResult(resultCode,requestCode,data);
      if(requestCode==PICK_IMAGE_REQUEST &amp;&amp; resultCode == RESULT_OK &amp;&amp; data != null &amp;&amp; data.getData() != null){
          Uri imageUri = data.getData();
          try{
              imageBitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),imageUri);
              x.uploadImage(imageBitmap,LaunchActivity.this);
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>There is no problem with the permission requesting process, the system permission dialog for external storage access comes up, gets granted and the picker opens up, but I can't select any image. Help will be appreciated!</p>