android- open gallery and choose image and video

Below code solved my problem

  final Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);
                        galleryIntent.setType("*/*");
                        startActivityForResult(galleryIntent, RESULT_LOAD_IMAGE);

You need use the following as picking Intent

Intent photoLibraryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
photoLibraryIntent.setType("image/* video/*");

You can use the next snippet:

Intent mediaChooser = new Intent(Intent.ACTION_GET_CONTENT);
//comma-separated MIME types
mediaChooser.setType("video/*, image/*");
startActivityForResult(mediaChooser, RESULT_LOAD_IMAGE);

But I think that it only work on ICS or bigger


On Android 6.0 and above using "video/* image/" or "image/ video/*" type doesn't work, it only recognizes the first filter you specify. I solved the problem using this code:

Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("*/*");
photoPickerIntent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] {"image/*", "video/*"});
startActivityForResult(photoPickerIntent, Constants.SELECT_PHOTO);

Although this will ask the user which app they want to use to select the image/video.