在 Android 应用程序中查看 MS Office 文件

发布于 2024-10-13 04:48:11 字数 646 浏览 2 评论 0原文

我正在尝试查看应用程序中的文件,例如音频、视频、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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

动次打次papapa 2024-10-20 04:48:11

你可以尝试一下。创建一个 ACTION_VIEW Intent,其中包含外部存储上文档的 Uri 以及适用于任何类型文件的正确 MIME 类型。使用 PackageManagerqueryIntentActivities() 查看是否有任何匹配项。如果没有匹配,则用户没有安装这样的应用程序。

You can try. Create an ACTION_VIEW Intent with a Uri to the document on external storage and the proper MIME type for whatever sort of file it is. Use PackageManager and queryIntentActivities() to see if there are any matches. If there are no matches, then the user does not have such an application installed.

调妓 2024-10-20 04:48:11

不完全了解您的用例,但 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文