打开本地PDF文件

作者: 瑟闻风倾 | 来源:发表于2019-12-05 15:38 被阅读0次
String documentPath= LocalPathCenter.maintainPath(documentName, LocalPathCenter.USERDOCUMENT);
files=new File(documentPath);
if (files.exists()){
  openPdf(files);
}

private void openPdf(File file){
  Uri path = Uri.fromFile(file);
  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.setDataAndType(path, "application/pdf");
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  try {
    activity.startActivity(intent);
  } catch (ActivityNotFoundException e) {
    e.printStackTrace();
  }
}

相关文章

网友评论

    本文标题:打开本地PDF文件

    本文链接:https://www.haomeiwen.com/subject/ypndgctx.html