View MS office files in an android application

霸气de小男生 提交于 2019-12-07 15:38:07

问题


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

回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4775295/view-ms-office-files-in-an-android-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!