我的应用程序创建了一个与标准 .PNG 向后兼容的自定义 .PNG 文件,但我希望我的应用程序能够识别我的特殊 .PNG(而不是默认为 Gallery)。创建图像后,我尝试将其注册为自定义 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 的任何想法?