Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is ParcelFileDescriptor in android

Tags:

android

I read about ParcelFileDescriptor from below link.

http://developer.android.com/reference/android/os/ParcelFileDescriptor.html

but I haven't got any idea from it. What is it? and What can it do?

Can anyone explain me?

like image 478
user829821 Avatar asked Jul 16 '11 06:07

user829821


2 Answers

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. The returned file descriptor is a dup of the original file descriptor: the object and fd is different, but operating on the same underlying file stream, with the same position.

and What can it do?

Create pipes, create fds from sockets, open/close files.

like image 77
Reno Avatar answered Sep 28 '22 10:09

Reno


It implements the Parcable API, which allow put it into Bundles and Intents. It may be even possible to send a FileDescriptor between process. (I have not tested this).

Also the VPNService gives you a ParcelFileDescriptor.

like image 33
plaisthos Avatar answered Sep 28 '22 09:09

plaisthos