查看Android应用程序MS Office文件应用程序、文件、Android、Office

2023-09-05 00:58:56 作者:啥是社会儿?

我想在我的应用程序,如音频,视频,PDF等文件的查看。

我已经成功地做​​到这一点,现在我想以查看Microsoft Office文件,如DOC,DOCX,XLS和PPT。

有没有办法做到这一点在Android中,比如调用意图是什么?

我这么AP preciated的任何帮助或指导。

修改

我已经下载ThinkFree的办公室,我的Nexus S,但下面的code还是返回false,请看看吧:

 私人布尔checkViewerAvailability(字符串类型)
 {
    PackageManager packageManager = getPackageManager();
    意向意图=新的意图(Intent.ACTION_VIEW);
    intent.setType(应用程序/文件);

    名单< ResolveInfo>表= packageManager.queryIntentActivities(意向,PackageManager.MATCH_DEFAULT_ONLY);
    返回则为list.size()> 0;
}
 

解决方案 office 2007 密钥ms系统软件工具下载

您可以试试。创建一个 ACTION_VIEW 意图乌里到文档上外部存储和适当的MIME类型,任何文件的排序是。使用 PackageManager queryIntentActivities()来看看是否有任何匹配。如果没有匹配,则该用户不具有安装这样的应用

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;
}

解决方案

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.