在我的应用程序中,我将收到一个字节流并将其转换为手机内存中的pdf文件.如何将其呈现为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)