我如何在Android中读取SD卡中的PDF文件?

我如何在Android中读取SD卡中的PDF文件?,android,pdf,sd-card,Android,Pdf,Sd Card,我的SD卡上保存了一个.PDF文件。我需要阅读.PDF文件的内容并在文本视图中显示它 如何执行此操作?例如,您可以使用类似的方法-获取文件路径并将其作为新的意图打开: // get the file path from the external storage (SD card) File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/yourPdfName.pdf"); Intent

我的SD卡上保存了一个.PDF文件。我需要阅读.PDF文件的内容并在文本视图中显示它


如何执行此操作?

例如,您可以使用类似的方法-获取文件路径并将其作为新的意图打开:

// 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);

这将不会在TxtView中显示pdf文件的内容。请查看此问题,以便在textView中显示它