I am playing with Android 4.4 PDF renderer and do not understnad what getSeekableFileDescriptor() is.
PdfRenderer renderer = new PdfRenderer(getSeekableFileDescriptor());
This function performs no validation of the Unix file descriptor argument, fd. Android uses the value -1 to represent an invalid file descriptor, all other values are considered valid. The validity of a file descriptor can be checked with FileDescriptor::valid ().
What it is? A file descriptor is an object that a process uses to read or write to an open file and open network sockets. FileDescriptorobjects, representing raw Linux file descriptor identifiers, can be written and ParcelFileDescriptorobjects returned to operate on the original file descriptor.
3 Answers 3. What it is? A file descriptor is an object that a process uses to read or write to an open file and open network sockets. FileDescriptor objects, representing raw Linux file descriptor identifiers, can be written and ParcelFileDescriptor objects returned to operate on the original file descriptor.
Returns the Unix file descriptor represented by the given java.io.FileDescriptor. Sets the Unix file descriptor represented by the given java.io.FileDescriptor. Returns a new java.io.FileDescriptor. The FileDescriptor created represents an invalid Unix file descriptor (represented by a file descriptor value of -1).
Some of Google's code snippets use placeholders for methods providing data required by the sample.
In this case, getSeekableFileDescriptor()
needs to return a ParcelFileDescriptor
that PdfRenderer
can use. In particular, it needs to be "seekable", meaning that a stream opened on the ParcelFileDescriptor
needs to be one that can be seeked forwards and backwards. For example, the static open()
method on ParcelFileDescriptor
gives you a seekable descriptor; createPipe()
does not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With