相关疑难解决方法(0)

如何在Android中呈现PDF

在我的应用程序中,我将收到一个字节流并将其转换为手机内存中的pdf文件.如何将其呈现为pdf?并在活动中展示它?

java pdf android

78
推荐指数
4
解决办法
8万
查看次数

从SD卡读取pdf文件

我想阅读存储在我的SD卡中的pdf文件,我尝试使用这个片段

    File file = new File(Environment.getExternalStorageDirectory()
            + "/vvveksperten" + "/ypc.pdf");

    PackageManager packageManager = getPackageManager();
    Intent testIntent = new Intent(Intent.ACTION_VIEW);
    testIntent.setType("application/pdf");
    List list = packageManager.queryIntentActivities(testIntent,
            PackageManager.MATCH_DEFAULT_ONLY);
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    Uri uri = Uri.fromFile(file);
    intent.setDataAndType(uri, "application/pdf");
    startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

但它给了我一个错误.

ERROR/AndroidRuntime(2611): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/vvveksperten/ypc.pdf typ=application/pdf }
Run Code Online (Sandbox Code Playgroud)

android

3
推荐指数
2
解决办法
7675
查看次数

标签 统计

android ×2

java ×1

pdf ×1