引用:http://bbs.wps.cn/thread-22327642-1-1.html
以下是指定使用WPS中文版打开文档的代码示例(WPS不同语言版的包名略有不同,请注意红色标记部分哦):
<打开文件>
调用startActivity 打开, 具体如下:
boolean openFile(String path)
{
Intent intent = new Intent();
Bundle bundle = new Bundle();<span style="white-space:pre"> </span>//根据不同情况设置要求
<span style="white-space:pre"> </span>//下面的budle都是控制情景的
bundle.putString(OPEN_MODE, READ_ONLY);
bundle.putBoolean(SEND_CLOSE_BROAD, true);
bundle.putString(THIRD_PACKAGE, selfPackageName);
bundle.putBoolean(CLEAR_BUFFER, true);
bundle.putBoolean(CLEAR_TRACE, true);
//bundle.putBoolean(CLEAR_FILE, true);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setClassName(packageName, className);
File file = new File(path);
if (file == null || !file.exists())
{ return false;
}
Uri uri = Uri.fromFile(file);
intent.setData(uri);
intent.putExtras(bundle);
try
{
startActivity(intent);
}
catch (ActivityNotFoundException e)
{
e.printStackTrace();
return false;
}
return true;
}
支持方式
关闭文件
保存文件
打开文件
给大家提供一个Demo下载地址: Android_WPS.rar
原文:http://blog.csdn.net/u010962482/article/details/46126097