关于Android外部应用启动wps的处理

   废话不多说 ,直接上马...    


   //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


   

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值