废话不多说 ,直接上马...
//txz start {
boolean openFile(){
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("OpenMode", "ReadMode");
bundle.putBoolean("SendCloseBroad", true);
bundle.putString("ThirdPackage", "com.android.settings");
bundle.putBoolean("ClearBuffer", true);
bundle.putBoolean("ClearTrace", true); //这部分都是一些参数 ,wps官网上有解释,大家自己可以去看
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction("android.intent.action.VIEW");
intent.setAction("android.intent.action.EDIT");
intent.setType("application/pdf");//这两个参数时重点,小弟我开始没有设置这两个参数,"cn.wps.moffice_i18n"这个版本的wps始终无法打开pdf文档,最后通过反编译才找到这两东东的
intent.setClassName("cn.wps.moffice_i18n", "cn.wps.moffice.documentmanager.PreStartActivity");//包名 类名 不多说
File file = null;
if(Locale.getDefault().getLanguage().equals("en")){//语言判断
file = new File("/文件名");
}else if(Locale.getDefault().getLanguage().equals("th")){
file = new File("文件名");
}
if (file == null || !file.exists())
{
return false;
}
Uri uri = Uri.fromFile(file);
intent.setData(uri);
intent.putExtras(bundle);
try
{
getActivity().startActivity(intent);
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
//txz end