Search code examples
androidandroid-5.0-lollipop

How to pick image or video on Android L?


I am using below code and it works fine below android 5. I am able to pick image or video from SD card.

Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("video/* image/*");
getActivity().startActivityForResult(photoPickerIntent, 1);

However on Android L it shows only videos. tried searching but didn't find anything, any help will be appreciated.


Solution

  • hi @Mohit you can use this solution for image and video

    Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
    photoPickerIntent.setType("*/*");
    getActivity().startActivityForResult(photoPickerIntent, 1);
    

    for both image and video you can use setType(*/*);

    here ACTION_GET_CONTENT is give only gallery selection while ACTION_PICK give many more options to pick image and video from different action, So as per @DipeshDhakal answer you should use only ACTION_GET_CONTENT.

    and this is work on android L and api 10 also.