In principle, you could create a ContentProvider
that serves up the ZipInputStream
.
In this sample project I demonstrate how to create a ContentProvider
supporting openFile()
that uses a pipe created by ParcelFileDescriptor.createPipe()
to serve up a file. createPipe()
returns a pair (two-element array) of ParcelFileDescriptors
representing the ends of the pipe. You use the second element out of the array to write to via an OutputStream
; openFile()
returns the first element out of the array to be passed by Android to the calling process. The caller would use openInputStream()
to read in what you transfer via the pipe.
In my case, I am sending an asset on which I get an InputStream
via AssetManager
. In your case, you would use your ZipInputStream
.
Note that my sample project assumes it is being run on a device that has a PDF viewer, since it is serving a PDF out of assets and trying to open it via startActivity()
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…