Doc, ppt, xls mime type

I am trying to open doc, ppt, xls and pfg files with an application installed with an intent. For pdf I am using i.setDataAndType(Uri.fromFile(file), "application/pdf"); but if I do the following:

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

I get an exception saying that there are no applications that can handle intentions. What am I doing wrong? I have QuickOffice installed, so I think it can open the file.

+4
source share
2 answers

Here's a link to the "official" mime types for Microsoft Office files. You will probably be more fortunate if you use "application / msword" instead of "application / doc".

You can also ask the OS to determine the appropriate mime type for the file:

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

We hope that any application that registers the mime type that can handle will lead to an update of the mime type map.

+17
source

Another way to get the exact mime type from a path or file url:

 String mimeType = URLConnection.guessContentTypeFromName(url); 
0
source

All Articles