Amren Amren - 4 months ago 31
Android Question

Unable to select image from gallery android app (grayed out)

I'm trying to allow the app user to select an image from their gallery and only set the image uri if the user actually selects it. The problem I'm facing is that when I open the gallery of images all of the images are grayed out and I cannot select an image regardless of the image format. Here is my code for that section:

hostImageView.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent imageIntent = new Intent();
startActivityForResult(Intent.createChooser(imageIntent,"Choose host image"),000);


public void onActivityResult(int askCode, int retCode, Intent info){
if (retCode==RESULT_OK){
if (askCode==000){


Update your code for gallery opening as follows:

Intent intent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 2);

And use the number 2(Or the number you are using for starting activity) inside onActivityResult method