Android 中的多种 MIME 类型 [英] Multiple MIME types in Android
本文介绍了Android 中的多种 MIME 类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法使用 intent.setType()
并提供多种广泛的类型(如图像和视频)?
Is there a way to use intent.setType()
and supply multiple broad types (like images and video)?
我正在使用 ACTION_GET_CONTENT
.它似乎只适用于逗号分隔的类型.
I am using an ACTION_GET_CONTENT
. It seems to be working with just comma-separated types.
推荐答案
在 Android 4.4 中使用 存储访问框架您可以使用EXTRA_MIME_TYPES
传递多种 mime 类型.
In Android 4.4 when using the Storage Access Framework you can use the EXTRA_MIME_TYPES
to pass multiple mime types.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
String[] mimetypes = {"image/*", "video/*"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
startActivityForResult(intent, REQUEST_CODE_OPEN);
这篇关于Android 中的多种 MIME 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文