打开本地PDF文件
2019-12-05 本文已影响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();
}
}