Android: Let user pick image or video from Gallery

后端 未结 8 610
死守一世寂寞
死守一世寂寞 2021-01-30 20:44

Is it possible to to start Gallery in such a way so both pictures and videos are shown?

Thanks

8条回答
  •  被撕碎了的回忆
    2021-01-30 21:24

    Pick Audio file from Gallery:

    //Use MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI);
    

    Pick Video file from Gallery:

    //Use MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
    

    Pick Image from gallery:

    //Use  MediaStore.Images.Media.EXTERNAL_CONTENT_URI
    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    

    Pick Media Files or images:

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

提交回复
热议问题