Question

I have some images in my emulator sdcard and i want to select a particular image on it. refer my code below,

int RESULT_LOAD_IMAGE = 1;
Intent i = new                   Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
            startActivityForResult(i, RESULT_LOAD_IMAGE);

Actually push a png image in my emulator sd card , but use the above code my emulator shows no media found. guide me,

Was it helpful?

Solution

Pick image using external app help(like gallery)?

public void pick(View V) {
    Intent it = new Intent();
    it.setType("image/*");
    it.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(it, 101);
}

I used onActivityResult here to output it on imageView later And you can convert it to URI, Bitmap or whatever you need

OTHER TIPS

try this,

Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);    

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { 
super.onActivityResult(requestCode, resultCode, imageReturnedIntent); 

switch(requestCode) { 
case 1:
    if(resultCode == RESULT_OK){  
        Uri selectedImage = imageReturnedIntent.getData();
        InputStream imageStream = getContentResolver().openInputStream(selectedImage);
        Bitmap yourSelectedImage = BitmapFactory.decodeStream(imageStream);
    }
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top