【发布时间】:2015-03-04 07:52:35
【问题描述】:
我搜索了很多,但没有在我的项目中实现正确的代码,我想像普通书一样卷曲 PDF 文件的每一页,但无法做到,当我点击按钮 PDF 文件时在我的代码中从 SD 卡加载。
File file = new File("/sdcard/android.pdf");
if (file.exists()) {
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 {
startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast.makeText(MainActivity.this,
"No Application Available to View PDF",
Toast.LENGTH_SHORT).show();
}
}
【问题讨论】: