The intention of the gallery is showing only the image or the video not both?

I'm trying to allow a user to select an image or video from their device and currently it only shows the video or image depending on which is written first in the following code:

 Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

                //set type to include video too
                galleryIntent.setType("image/*, video/*");

                startActivityForResult(galleryIntent, GALLERY_IMAGE_REQUEST_CODE);
            }
        };

      

not sure what i am doing wrong but the setType seems to be correct, i tried with and without comma between image and video ...

+3


source to share


3 answers


 case 2: //Choose Pic

                            Intent choosePhotoIntent = new Intent(Intent.ACTION_GET_CONTENT);
                            choosePhotoIntent.setType("image/*");
                            startActivityForResult(choosePhotoIntent, PICK_PHOTO_REQUEST);
                            break;
                        case 3: //Choose Video
                            Intent chooseVideoIntent = new Intent(Intent.ACTION_GET_CONTENT);
                            chooseVideoIntent.setType("video/*");
                            Toast.makeText(MyActivity.this,getString(R.string.video_message), Toast.LENGTH_LONG).show();
                            startActivityForResult(chooseVideoIntent, PICK_VIDEO_REQUEST);
                            break;

      



Try the above. You need to have separate options.

0


source


I ran into the same problem where it would only use the first MIME type in the list.

This ended for me:



Intent intent = new Intent(Intent.ACTION_GET_CONTENT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("*/*");
String[] mimeTypes = {"image/*", "video/*"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
startActivityForResult(intent, REQUEST_CODE_CAMERA_ROLL);

      

0


source


This works for me:

Intent gallery = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(gallery, PICK_MEDIA);

      

0


source







All Articles