gpt4 book ai didi

Android 如何将 PDF 文件作为字节数组传递给 Intent

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:40:11 24 4
gpt4 key购买 nike

我有一项 Activity 允许用户使用默认的 pdf/ebook 查看器打开加密的 pdf 文件。加密pdf文件的解密结果是一个字节数组。我想将该字节数组传递给以 PDF 形式打开该字节数组的 Intent 。 Intent 实例化是这样的:

PackageManager pm = PackageManager;
Intent intentPdf = pm.GetLaunchIntentForPackage("com.adobe.android");

这可能吗? pdf 阅读器(Adobe/任何其他)能否从字节数组中理解它是 PDF 文件?我尝试使用 Bundle.PutByteArray 和 Intent.putExtra,但它不起作用。

var bundle = new Bundle();
bundle.PutByteArray("key", inputFileData);
intentPdf.PutExtra("name", bundle);
StartActivity(intentPdf);

inputFileData 是我的字节数组。

最佳答案

Can the pdf reader (Adobe/any other) understand from a byte array that it's a PDF file?

可能不会。欢迎您联系这些应用程序的开发者并询问他们。而且,正如其他人指出的那样,由于尺寸问题,这是一个坏主意。此外,如果您启动的 PDF 查看器恰好启动了它自己的任务,your byte array will be readable by any app on the device .

或者,欢迎您使用 ContentProvider,例如 this one ,您可以在其中计算出一些一次性使用的 Uri 结构,因此一旦 PDF 查看器使用了 Uri,其他任何东西都无法使用。

或者,欢迎您编写自己的基于字节数组的 PDF 查看器。

关于Android 如何将 PDF 文件作为字节数组传递给 Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13179559/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com