开发者

Doc, ppt, xls mime type

I try to open doc开发者_StackOverflow社区, ppt, xls and pfg files with app installed via intent. For pdf I use i.setDataAndType(Uri.fromFile(file), "application/pdf"); but if I do following:

i.setDataAndType(Uri.fromFile(file), "application/doc");

I receive exception, saying that there are no apps, that can handle intent. What am I doing wrong? I've got QuickOffice installed, so I think it could open file.


Here's a link to the 'official' mime types for Microsoft Office files. You'll probably have better luck if you use "application/msword" in place of "application/doc".

You can also have the OS try to determine the appropriate mime type for a file:

String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(url));

Hopefully any application that registers a mime type that it can handle will cause the mime type map to be updated.


Another way to get exact mime type from file path or URL is:

String mimeType = URLConnection.guessContentTypeFromName(url);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜