Open Gallery App in Android

て烟熏妆下的殇ゞ 提交于 2019-11-30 04:14:29

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! :)

Biraj Zalavadia

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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!