【发布时间】:2015-05-29 08:20:08
【问题描述】:
我的 SD 卡上保存了一个 .PDF 文件。我需要阅读 .PDF 文件的内容并将其显示在 TextView 中。
我该怎么做?
【问题讨论】:
我的 SD 卡上保存了一个 .PDF 文件。我需要阅读 .PDF 文件的内容并将其显示在 TextView 中。
我该怎么做?
【问题讨论】:
例如,您可以使用类似的东西 - 获取文件路径并将其作为新意图打开:
// get the file path from the external storage (SD card)
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/yourPdfName.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
// set the content type and data of the intent
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
// start the intent as a new activity
startActivity(intent);
【讨论】: