在 Android 应用程序中查看 MS Office 文件
我正在尝试查看应用程序中的文件,例如音频、视频、PDF 等。
我已经成功地做到了这一点,现在我正在尝试查看 Microsoft Office 文件,例如 doc、docx、xls 和 ppt。
在android中有什么办法可以做到这一点,比如调用Intent吗?
我非常感谢任何帮助或指导。
编辑
我已将thinkfree office下载到我的nexus S,但以下代码仍然返回false,请查看:
private boolean checkViewerAvailability(String type)
{
PackageManager packageManager = getPackageManager();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType("application/doc");
List<ResolveInfo> list = packageManager.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
I am trying to view files in my application such as audio, video , PDF and others.
I have successfully done that, now I am trying to view Microsoft office files such as doc, docx, xls and ppt.
Is there any way to do that in android, like calling an Intent?
I am so appreciated for any help or guide.
Edit
I have downloaded thinkfree office to my nexus S, but the following code still returning false, kindly look at it:
private boolean checkViewerAvailability(String type)
{
PackageManager packageManager = getPackageManager();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setType("application/doc");
List<ResolveInfo> list = packageManager.queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以尝试一下。创建一个
ACTION_VIEW
Intent
,其中包含外部存储上文档的Uri
以及适用于任何类型文件的正确 MIME 类型。使用PackageManager
和queryIntentActivities()
查看是否有任何匹配项。如果没有匹配,则用户没有安装这样的应用程序。You can try. Create an
ACTION_VIEW
Intent
with aUri
to the document on external storage and the proper MIME type for whatever sort of file it is. UsePackageManager
andqueryIntentActivities()
to see if there are any matches. If there are no matches, then the user does not have such an application installed.不完全了解您的用例,但 Google 文档将接受这些格式并将其转换为可在 Android 上编辑的本机 Gdocs。
Don't exactly get your use case, but Google docs will accept and translate those formats to native Gdocs that can be edited on android.