Reputation: 839
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,
Upvotes: 0
Views: 117
Reputation: 2475
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
Upvotes: 2
Reputation: 76
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);
}
}
}
Upvotes: 0