【发布时间】:2011-10-27 00:16:09
【问题描述】:
我的应用创建了一个与标准 .PNG 向后兼容的自定义 .PNG 文件,但我希望我的应用能够识别我的特殊 .PNG(而不是默认为图库)。创建图像后,我尝试将其注册为自定义 MIME 类型,但它们仍被扫描为常规 PNG。
File file = new File("/mnt/sdcard/custom.png");
//now scan the file into the content database
MediaScannerConnection.scanFile(this,
new String[] { file.toString() }, new String[] { "image/x-custom" },
new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Log.i("ExternalStorage", "Scanned " + path + ":");
Log.i("ExternalStorage", "-> uri=" + uri);
ContentResolver cr = getContentResolver();
String mime = cr.getType(uri);
//mime returns image/png, not image/x-custom :(
}
关于如何让 Android 识别我的自定义 MIME 类型和/或允许我的应用识别扩展的 .PNG 的任何想法?
【问题讨论】:
-
似乎不支持自定义 mime 类型 :(
标签: android mime android-mediascanner