I am trying to open inbuilt gallery app pressing a button in my app.
I am trying out on Android 2.3 and above phones. The phones/tablet that I have are
Samsung
I figured out the way..
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(
"content://media/internal/images/media"));
startActivity(intent);
This piece of code just opened the gallery without any issues. Could get it working on all versions!
Thought to put it as answer for people who are looking to open a Gallery on all versions.
Thanks Guys! :)
Try This out
btnGallery.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, ""), PICK_IMAGE);
}
});
UPDATE onActivityResult
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != Activity.RESULT_CANCELED) {
if (requestCode == PICK_IMAGE) {
Uri selectedImageUri = data.getData();
}
}
}
UPDATE TO OPEN GALLERY APP
Intent galleryIntent = new Intent(Intent.ACTION_VIEW, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivity(galleryIntent);
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(
Intent.createChooser(intent, "Complete action using"),
PICK_FROM_FILE);