I have an activity which allows users to open encrypted pdf files with a default pdf/ebook viewer. The result of the decryption of an encrypted pdf file is a byte array. I want to pass that byte array to an intent which opens that byte array as a PDF. The intent instantiation is something like this:
PackageManager pm = PackageManager;
Intent intentPdf = pm.GetLaunchIntentForPackage("com.adobe.android");
Is this possible? Can the pdf reader (Adobe/any other) understand from a byte array that it’s a PDF file?
I tried with Bundle.PutByteArray and Intent.putExtra but it won’t work.
var bundle = new Bundle();
bundle.PutByteArray("key", inputFileData);
intentPdf.PutExtra("name", bundle);
StartActivity(intentPdf);
inputFileData is my byte array.
Probably not. You are welcome to contact the developers of those apps and ask them. And, as others have pointed out, this is a bad idea due to size issues. Also, if the PDF viewer you launch happens to start its own task, your byte array will be readable by any app on the device.
Or, you are welcome to use a
ContentProvider, like this one, where you work out some single-useUristructure, so once the PDF viewer uses theUri, nothing else can.Or, you are welcome to write your own PDF viewer that works off of a byte array.