我正在使用下面的代码,它在 android 5
下运行良好。我可以从 SD 卡中选择图像或视频。
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("video/* image/*");
getActivity().startActivityForResult(photoPickerIntent, 1);
但是在 Android L
上它只显示视频。
尝试搜索但未找到任何内容,我们将不胜感激。
最佳答案
您好@Mohit,您可以将此解决方案用于图像和视频
Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
photoPickerIntent.setType("*/*");
getActivity().startActivityForResult(photoPickerIntent, 1);
对于图像和视频,您可以使用 setType(*/*);
此处 ACTION_GET_CONTENT 仅提供画廊选择,而 ACTION_PICK 提供更多选项以从不同的操作中选择图像和视频,因此根据@DipeshDhakal 的回答,您应该仅使用 < strong>ACTION_GET_CONTENT。
这也适用于 android L 和 api 10。
关于android - 如何在 Android L 上选择图像或视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31380013/