3

I have an Android app that among other things is able to download documents. I would like to offer the ability to open these documents with other apps like DataViz's Documents To Go viewer apps. I've looked at quite a bit of code and searched through the other questions on here and I think I'm just not doing something quite right.

For example, let's pretend I'm downloading a ppt. This bit of code is supposed to verify that the document type is supported by an app before downloading the document.

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setType("application/ppt");

    PackageManager packageManager = getPackageManager();
    List intentList = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (intentList.size() == 0) {
      // error
    }

For some reason this bit of code doesn't register DataViz's apps or the other document viewer on my device.

And of course, if I were to call startActivity(intent); that would throw an exception.

Daniel
  • 132
  • 1
  • 12

1 Answers1

5

Try using application/vnd.ms-powerpoint as the mime type.

Femi
  • 64,273
  • 8
  • 118
  • 148
  • Thanks! That was the clue that I needed. Ultimately I need to be able to determine the mimetype from the file extension. So the following code fixes that. Assume that the var datatype has the file's extention. e.g. "ppt" MimeTypeMap tMimeType = MimeTypeMap.getSingleton(); String mimeType = tMimeType.getMimeTypeFromExtension(datatype); intent.setType(mimeType); – Daniel May 26 '11 at 04:02