【问题标题】:How I read file PDF in SD card in Android? [duplicate]如何在 Android 中读取 SD 卡中的 PDF 文件? [复制]
【发布时间】:2015-05-29 08:20:08
【问题描述】:

我的 SD 卡上保存了一个 .PDF 文件。我需要阅读 .PDF 文件的内容并将其显示在 TextView 中。

我该怎么做?

【问题讨论】:

    标签: android pdf sd-card


    【解决方案1】:

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

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-03
    • 2011-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多