Example usage for android.os MemoryFile writeBytes

List of usage examples for android.os MemoryFile writeBytes

Introduction

In this page you can find the example usage for android.os MemoryFile writeBytes.

Prototype

public void writeBytes(byte[] buffer, int srcOffset, int destOffset, int count) throws IOException 

Source Link

Document

Write bytes to the memory file.

Usage

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  ww w.  ja v  a2s . co 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();
            }
        }
    }
}