Code example for Parcel

Methods: dataPositionsetDataPositionwriteInt

0
    } 
 
    // Write the number of bytes from the offset to the current 
    // position at position pointed by offset. 
    private void adjustSize(int offset) {
        final int pos = mParcel.dataPosition();
 
        mParcel.setDataPosition(offset);
        mParcel.writeInt(pos - offset);
        mParcel.setDataPosition(pos);
    } 
 
    // Rewind the parcel and insert the header. 
    private void resetParcel() { 
        mParcel.setDataPosition(0);
        // Most tests will use a properly formed parcel with a size 
        // and the meta marker so we add them by default. 
        mParcel.writeInt(-1);  // Placeholder for the size
        mParcel.writeInt(kMarker);
    }