本文整理了Java中android.os.Parcel.writeByteArray()
方法的一些代码示例,展示了Parcel.writeByteArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parcel.writeByteArray()
方法的具体详情如下:
包路径:android.os.Parcel
类名称:Parcel
方法名:writeByteArray
[英]Write a byte array into the parcel at the current #dataPosition, growing #dataCapacity if needed.
[中]将字节数组写入当前#数据位置的包中,如果需要,增加#数据容量。
代码示例来源:origin: johncarl81/parceler
@Override
public void nullSafeToParcel(byte[] input, Parcel parcel) {
parcel.writeByteArray(input);
}
};
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(owner);
dest.writeByteArray(privateData);
}
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(id);
dest.writeByteArray(data);
}
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(ptsAdjustment);
dest.writeLong(identifier);
dest.writeInt(commandBytes.length);
dest.writeByteArray(commandBytes);
}
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mimeType);
dest.writeString(filename);
dest.writeString(description);
dest.writeByteArray(data);
}
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mimeType);
dest.writeString(description);
dest.writeInt(pictureType);
dest.writeByteArray(pictureData);
}
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(key);
dest.writeInt(value.length);
dest.writeByteArray(value);
dest.writeInt(localeIndicator);
dest.writeInt(typeIndicator);
}
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(uuid.getMostSignificantBits());
dest.writeLong(uuid.getLeastSignificantBits());
dest.writeString(licenseServerUrl);
dest.writeString(mimeType);
dest.writeByteArray(data);
dest.writeByte((byte) (requiresSecureDecryption ? 1 : 0));
}
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(schemeIdUri);
dest.writeString(value);
dest.writeLong(presentationTimeUs);
dest.writeLong(durationMs);
dest.writeLong(id);
dest.writeByteArray(messageData);
}
代码示例来源:origin: google/ExoPlayer
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(colorSpace);
dest.writeInt(colorRange);
dest.writeInt(colorTransfer);
Util.writeBoolean(dest, hdrStaticInfo != null);
if (hdrStaticInfo != null) {
dest.writeByteArray(hdrStaticInfo);
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testByteArrayToleratesZeroes() {
parcel.writeInt(19); // Length
parcel.writeInt(0); // These are zero
parcel.writeLong(0); // This is zero
parcel.writeFloat(0.0f); // This is zero
parcel.writeByteArray(new byte[0]); // This is also zero
assertThat(parcel.dataSize()).isEqualTo(24);
parcel.setDataPosition(0);
assertThat(parcel.createByteArray()).isEqualTo(new byte[19]);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testByteArrayOfZeroesReadAsZeroes() {
parcel.writeByteArray(new byte[15]);
assertThat(parcel.dataSize()).isEqualTo(20);
parcel.setDataPosition(0);
assertThat(parcel.readInt()).isEqualTo(15);
assertThat(parcel.readLong()).isEqualTo(0);
assertThat(parcel.readLong()).isEqualTo(0);
assertThat(parcel.dataPosition()).isEqualTo(20);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testByteArrayOfZeroesCastedToZeroes() {
parcel.writeByteArray(new byte[17]);
assertThat(parcel.dataSize()).named("total size").isEqualTo(24);
parcel.setDataPosition(0);
assertThat(parcel.readInt()).isEqualTo(17);
assertThat(parcel.readInt()).isEqualTo(0);
assertThat(parcel.readFloat()).isEqualTo(0.0f);
assertThat(parcel.createByteArray()).isEqualTo(new byte[0]);
assertThat(parcel.readString()).isEqualTo("");
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testWriteAndCreateNullByteArray() throws Exception {
parcel.writeByteArray(null);
assertThat(parcel.dataSize()).isEqualTo(4);
parcel.setDataPosition(0);
assertThat(parcel.createByteArray()).isNull();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testWriteAndCreateByteArray_lengthZero() {
byte[] bytes = new byte[] {};
parcel.writeByteArray(bytes);
assertThat(parcel.dataSize()).isEqualTo(4);
parcel.setDataPosition(0);
byte[] actualBytes = parcel.createByteArray();
assertTrue(Arrays.equals(bytes, actualBytes));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testWriteAndReadByteArray() {
byte[] bytes = new byte[] { -1, 2, 3, 127 };
parcel.writeByteArray(bytes);
assertThat(parcel.dataSize()).isEqualTo(8);
parcel.setDataPosition(0);
byte[] actualBytes = new byte[bytes.length];
parcel.readByteArray(actualBytes);
assertTrue(Arrays.equals(bytes, actualBytes));
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = RuntimeException.class)
public void testWriteAndReadByteArray_nullNotAllowed() {
parcel.writeByteArray(null);
assertThat(parcel.dataSize()).isEqualTo(4);
parcel.setDataPosition(0);
byte[] actualBytes = new byte[1];
parcel.readByteArray(actualBytes);
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = RuntimeException.class)
public void testWriteAndReadByteArray_badLength() {
byte[] bytes = new byte[] { -1, 2, 3, 127 };
parcel.writeByteArray(bytes);
assertThat(parcel.dataSize()).isEqualTo(8);
parcel.setDataPosition(0);
byte[] actualBytes = new byte[1];
parcel.readByteArray(actualBytes);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testWriteAndCreateByteArray_oddLength() {
byte[] bytes = new byte[] {-1, 2, 3, 127, -128};
parcel.writeByteArray(bytes);
assertWithMessage("4B length + 5B data + 3B padding").that(parcel.dataSize()).isEqualTo(12);
parcel.setDataPosition(0);
assertThat(parcel.createByteArray()).isEqualTo(bytes);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testWriteAndCreateByteArray_multipleOf4() {
byte[] bytes = new byte[] {-1, 2, 3, 127};
parcel.writeByteArray(bytes);
// Make sure that the parcel is not storing the original array.
bytes[0] = 55;
bytes[1] = 55;
bytes[2] = 55;
bytes[3] = 55;
assertWithMessage("4B length + 4B data").that(parcel.dataSize()).isEqualTo(8);
parcel.setDataPosition(0);
byte[] actualBytes = parcel.createByteArray();
assertThat(actualBytes).isEqualTo(new byte[] {-1, 2, 3, 127});
}
内容来源于网络,如有侵权,请联系作者删除!