Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is getSeekableFileDescriptor() in this android doc?

Tags:

java

file

android

I am playing with Android 4.4 PDF renderer and do not understnad what getSeekableFileDescriptor() is.

PdfRenderer renderer = new PdfRenderer(getSeekableFileDescriptor());
like image 714
silversunhunter Avatar asked Nov 24 '14 00:11

silversunhunter


People also ask

How to check if a file descriptor is valid in Android?

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 is a file descriptor object?

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.

What is FileDescriptor in Linux?

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.

What does FileDescriptor-1 return?

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).


1 Answers

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.

like image 99
CommonsWare Avatar answered Oct 18 '22 18:10

CommonsWare