首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android pick意图

Android pick意图
EN

Stack Overflow用户
提问于 2012-07-06 16:32:47
回答 1查看 1.4K关注 0票数 5

我正在尝试选择具有这3种mime类型中的任何一种的文件,但它似乎不起作用

代码语言:javascript
复制
Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
photoPickerIntent.setType("image/*, video/*, audio/*");

有人能建议我怎么做吗?

EN

回答 1

Stack Overflow用户

发布于 2012-07-06 16:37:59

写下面的代码而不是你的代码,这可能会对你有帮助。

代码语言:javascript
复制
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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11358646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档