// Assume that 'parcel' is already initialized with some data int startPos = parcel->dataPosition(); // Save the current position std::string myString; parcel->readString(myString); // Read a string from the Parcel int endPos = parcel->dataPosition(); // Get the updated position int bytesMoved = endPos - startPos; // Determine how many bytes were read
// Assume that 'parcel' is already initialized int startPos = parcel->dataPosition(); // Save the current position int myInt = 42; parcel->writeInt(myInt); // Write an integer to the Parcel int endPos = parcel->dataPosition(); // Get the updated position int bytesMoved = endPos - startPos; // Determine how many bytes were writtenIn this example, we save the current position in the parcel object, write an integer to it, and then determine how many bytes were moved by subtracting the saved position from the updated position. Package library: Android Framework.