我试图选择一个包含这3种mime类型的文件,但似乎不起作用
Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
photoPickerIntent.setType("image/*, video/*, audio/*");
有人能建议我怎么做吗?
最佳答案
写下面的代码而不是你的代码,它可能会帮助你。
private static final int PICTURE = 0;
private static final int VIDEO = 1;
private static final int AUDIO = 2;
Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
String title = GET_PICTURE;
if (this.mediaType == PICTURE) {
photoPickerIntent.setType("image/*");
title = "GET_PICTURE";
}else if (this.mediaType == VIDEO) {
photoPickerIntent.setType("video/*");
title = "GET_VIDEO";
}else if (this.mediaType == AUDIO) {
photoPickerIntent.setType("audio/*");
title = "GET_AUDIO";
}
并使用下面的链接作为参考。
Pick Intent Example