在Android的开放.msg文件(Outlook项目文件)编程 [英] Opening .msg file(Outlook item file) in android programmatically
问题描述
我想通过我的应用程序打开一个.msg文件。我试着用设置MIMETYPE为 vnd.ms-前景
,不过我还是没能打开.msg文件如我所料,然后我试图与安装相同.MSG电子邮件和在我的设备打开。它开始像一个魅力。
I am trying to open a .MSG file through my application. I tried with setting the MIMETYPE as vnd.ms-outlook
, still i couldn't able to open up the .MSG file as i expected, then i tried with attaching the same .MSG in email and opened in my device. It opened like a charm.
所以我的问题是,我怎么能开辟Android的.msg文件编程中的应用程序。
So my question is , How can i open up the .MSG file in android programmatically within the application.
试着用下面的方法,
方法1:手动设置MIMETYPE
Method 1 : Setting the MIMETYPE manually
mimetype = "application/vnd.ms-outlook";
方法二:通过 MimeTypeMap
String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(file).toString());
String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); // extension is msg
通过其他安装的应用程序打开.msg文件
Opening the .MSG file through another installed application
Log.i(TAG, "Extension :" + extension + "\n" + "MIME :" + mimetype); // Prints msg for extension and mimetype = application/vnd.ms-outlook for method 1 and null when i use method 2
intent.setDataAndType(Uri.fromFile(file),mimetype);
startActivity(intent);
在方法2结果无效的MIMETYPE并设置明确的太不工作的媒体类型。
The mimetype in Method 2 results null and the mimetype set explicitly too doesn't work.
任何人可以分享他们的想法解决这个问题。
Could anybody share their thoughts on solving this issue.
感谢。
推荐答案
您应该使用的意图,与其他应用程序打开该文件。试试这个:
You should use an intent to open the file with another app. Try this:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(msgURI, mimeTypeString);
startActivity(i);
这应该允许已注册在其清单味精的数据类型将其打开任何应用程序。
That should allow any app that has registered the MSG's data type in its manifest to open it.
这篇关于在Android的开放.msg文件(Outlook项目文件)编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!