I am starting a request for an image pick:
Intent intent = new Intent();
intent.setType( \"image/*\" );
intent.setAction( Intent.ACTION_GET_CONTENT );
startActiv
This is the code to open gallery. However this the same what you have done. Also see the onActivityResult
code which I used to retrive the selected image.
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),
PHOTO_GALLERY);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case PHOTO_GALLERY:
if (resultCode == RESULT_OK) {
Uri selectedImageUri = Uri.parse(data.getDataString());
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(
getApplicationContext().getContentResolver(),
selectedImageUri);
this.postImagePreview.setImageBitmap( bitmap);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break;
}
}
}