【发布时间】:2011-07-07 12:06:03
【问题描述】:
我的活动可以显示图片库,我想定义一个“意图过滤器”,表明我的应用可以打开多张图片。例如,在用户拍照并想要浏览它之后,选择器对话框应该建议我的应用程序。
我知道清单中的这段代码只适用于一张图片:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
但它不适用于多张图片...
我认为 mimetype 的值不正确...但是打开媒体提供者图像的正确 mimetype 是什么?
以下是查看 google.note 的意图过滤器示例:
<intent-filter android:label="@string/resolve_edit">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
</intent-filter>
我尝试将“note”替换为“image”,但它不起作用......有什么想法吗?
我终于拿到了Gallery项目的源代码,这里是manifest文件:https://android.googlesource.com/platform/packages/apps/Gallery/+/master/AndroidManifest.xml
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="vnd.android.cursor.dir/image"/>
</intent-filter>
但它在我的 Nexus S 上无论如何都不起作用......
我在 Android 开发者网站上找到了这个:
对于多条记录:
vnd.android.cursor.dir/vnd.yourcompanyname.contenttype
例如,对所有火车记录的请求,如以下 URI,
content://com.example.transportationprovider/trains
可能会返回此 MIME 类型:
vnd.android.cursor.dir/vnd.example.rail
【问题讨论】:
-
你的意思是你想要一个布局中的多个图像?
-
我的意思是我在同一视图上显示图像矩阵,例如网格视图。
-
那么有什么问题吗?为什么你不使用贪婪视图
标签: android intentfilter