Android是不能直接打开pdf文件的,需要先下载到本地再去打开 LogUtil.d(LogUtil.CQ, "donwFile.path=" + response.getAbsolutePath()); String filePath = response.getAbsolutePath(); ...
Android是不能直接打开pdf文件的,需要先下载到本地再去打开
LogUtil.d(LogUtil.CQ, "donwFile.path=" + response.getAbsolutePath()); String filePath = response.getAbsolutePath(); if (response.exists()) { if (filePath.endsWith(".pdf")) { UIHelper.showPdfReader(mContext, filePath);//MyApplication. } else if(filePath.endsWith(".docx") || filePath.endsWith(".doc")) { /** * 打开Word文件的intent * @param param * @return */ try { Intent intent = new Intent("android.intent.action.VIEW"); intent.addCategory("android.intent.category.DEFAULT"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Uri uri ; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {//判断版本大于等于7.0 // "com.ansen.fileprovider.fileprovider"即是在清单文件中配置的authorities // 通过FileProvider创建一个content类型的Uri uri = FileProvider.getUriForFile(mContext, "com.broker.liming", new File(filePath)); intent.addFlags(Intent.FLA