安卓如何打开一个.doc文件的延伸?文件、doc

2023-09-12 22:41:21 作者:从初遇到陌路

有任何可能的方式来打开一个.doc文件的延伸?  如果可能的话,请告诉我该怎么做。 感谢名单

Is there any possible way to open a .doc extention file ? If possible then please tell me how to do it. Thanx

推荐答案

不同的iOS,安卓本身不支持渲染.doc或.PPT文件。您正在寻找一个公共的意图,让您的应用程序重复使用其他应用的活动,以显示这些文件类型。但是,这将只适用于支持该意向已经安装的应用程序的电话。

Unlike iOS, Android itself does not support rendering .doc or .ppt files. You are looking for a public intent that allows your app to reuse other apps' activities to display these document types. But this will only work for a phone that has an app installed that supports this Intent.

http://developer.android.com/guide/topics/intents/intents-filters.html

如果您已经安装了一些应用程序,然后使用此意图:

or if you have installed some app then use this Intent:

//Uri uri = Uri.parse("file://"+file.getAbsolutePath());
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(Intent.ACTION_VIEW);
String type = "application/msword";
intent.setDataAndType(Uri.fromFile(file), type);
startActivity(intent);