Example usage for android.os Parcel writeFileDescriptor

List of usage examples for android.os Parcel writeFileDescriptor

Introduction

In this page you can find the example usage for android.os Parcel writeFileDescriptor.

Prototype

public final void writeFileDescriptor(FileDescriptor val) 

Source Link

Document

Write a FileDescriptor into the parcel at the current dataPosition(), growing dataCapacity() if needed.

Usage

From source file:org.droid2droid.internal.RemoteBinderProxy.java

@Override
public void dump(FileDescriptor fd, String[] args) throws RemoteException {
    Parcel data = Parcel.obtain();
    data.writeFileDescriptor(fd);
    data.writeStringArray(args);/*  w ww.j a v a  2  s.co  m*/
    try {
        transact(DUMP_TRANSACTION, data, null, 0);
    } finally {
        data.recycle();
    }
}

From source file:edu.umich.flowfence.common.ParceledPayload.java

@Override
public void writeToParcel(Parcel dest, int flags) {
    if (data.length < INLINE_SIZE) {
        dest.writeByteArray(data);//from w  ww.  ja v  a 2 s. c o  m
    } else {
        dest.writeByteArray(null);
        MemoryFile mf = null;
        try {
            mf = new MemoryFile("ParceledPayload", data.length);
            mf.writeBytes(data, 0, 0, data.length);
            FileDescriptor ashmemFd = mf.getFileDescriptor();
            dest.writeFileDescriptor(ashmemFd);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if (mf != null) {
                mf.close();
            }
        }
    }
}