From 7ca72b9d0fe8a4d94b404474eb958e60e4860697 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 6 Nov 2011 17:00:25 -0500 Subject: [PATCH] Work around broken office suites by sending an explicit mime type with files we open --- src/com/fsck/k9/view/AttachmentView.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/fsck/k9/view/AttachmentView.java b/src/com/fsck/k9/view/AttachmentView.java index cf24aa322..9e9a4c441 100644 --- a/src/com/fsck/k9/view/AttachmentView.java +++ b/src/com/fsck/k9/view/AttachmentView.java @@ -239,8 +239,10 @@ public class AttachmentView extends FrameLayout { public void showFile() { Uri uri = AttachmentProvider.getAttachmentUriForViewing(mAccount, part.getAttachmentId()); Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(uri); - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + // We explicitly set the ContentType in addition to the URI because some attachment viewers (such as Polaris office 3.0.x) choke on documents without a mime type + intent.setDataAndType(uri, contentType); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); + try { mContext.startActivity(intent); } catch (Exception e) { @@ -271,7 +273,7 @@ public class AttachmentView extends FrameLayout { Uri uri = AttachmentProvider.getAttachmentUriForViewing(mAccount, part.getAttachmentId()); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); if (intent.resolveActivity(mContext.getPackageManager()) == null) { viewButton.setEnabled(false); }