从android资源获取MIME类型?

时间:2017-01-06 16:08:48

标签: android mime-types android-resources

如何从android资源URI获取MIME类型?

URI看起来像:

android.resource://com.package.name/drawable/resourceName

我试过

ContentResolver cR = context.getContentResolver();
MimeTypeMap mime = MimeTypeMap.getSingleton();
mimetype = mime.getExtensionFromMimeType(cR.getType(uri));

但返回的MIME类型为null

String url = uri.toString();
String extension = MimeTypeMap.getFileExtensionFromUrl(url);
mimetype = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);

但没有延期...

0 个答案:

没有答案