android.os.Parcel.readByteArray()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(277)

本文整理了Java中android.os.Parcel.readByteArray()方法的一些代码示例,展示了Parcel.readByteArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parcel.readByteArray()方法的具体详情如下:
包路径:android.os.Parcel
类名称:Parcel
方法名:readByteArray

Parcel.readByteArray介绍

[英]Read a byte[] object from the parcel and copy it into the given byte array.
[中]从包裹中读取字节[]对象,并将其复制到给定的字节数组中。

代码示例

代码示例来源:origin: google/ExoPlayer

private PrivateCommand(Parcel in) {
 ptsAdjustment = in.readLong();
 identifier = in.readLong();
 commandBytes = new byte[in.readInt()];
 in.readByteArray(commandBytes);
}

代码示例来源:origin: google/ExoPlayer

private MdtaMetadataEntry(Parcel in) {
 key = Util.castNonNull(in.readString());
 value = new byte[in.readInt()];
 in.readByteArray(value);
 localeIndicator = in.readInt();
 typeIndicator = in.readInt();
}

代码示例来源:origin: gotev/android-upload-service

@SuppressWarnings("unchecked")
protected ServerResponse(Parcel in) {
  httpCode = in.readInt();
  body = new byte[in.readInt()];
  in.readByteArray(body);
  headers = (LinkedHashMap<String, String>) in.readSerializable();
}

代码示例来源:origin: Polidea/RxAndroidBle

int serviceDataLength = in.readInt();
  byte[] serviceData = new byte[serviceDataLength];
  in.readByteArray(serviceData);
  if (in.readInt() == 0) {
    builder.setServiceData(servcieDataUuid, serviceData);
    int serviceDataMaskLength = in.readInt();
    byte[] serviceDataMask = new byte[serviceDataMaskLength];
    in.readByteArray(serviceDataMask);
    builder.setServiceData(
        servcieDataUuid, serviceData, serviceDataMask);
int manufacturerDataLength = in.readInt();
byte[] manufacturerData = new byte[manufacturerDataLength];
in.readByteArray(manufacturerData);
if (in.readInt() == 0) {
  builder.setManufacturerData(manufacturerId, manufacturerData);
  int manufacturerDataMaskLength = in.readInt();
  byte[] manufacturerDataMask = new byte[manufacturerDataMaskLength];
  in.readByteArray(manufacturerDataMask);
  builder.setManufacturerData(manufacturerId, manufacturerData,
      manufacturerDataMask);

代码示例来源: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_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(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: stackoverflow.com

public void writeToParcel(Parcel dest, int flags) {
  dest.writeString(type);
  dest.writeString(numberPlate);
  dest.writeString(brand);
  dest.writeDouble(pricePerHour);
  dest.writeDouble(pricePerKm);
  dest.writeString(objectId);
  dest.writeInt(photo.length());
  dest.writeByteArray(photo);
}


public void readFromParcel(Parcel in){
  this.type = in.readString();
  this.numberPlate = in.readString();
  this.brand = in.readString();
  this.pricePerHour = in.readDouble();
  this.pricePerKm = in.readDouble();
  this.objectId = in.readString();
  this.photo = new byte[in.readInt()];
  in.readByteArray(this.photo);
}

代码示例来源:origin: parse-community/Parse-SDK-Android

source.readByteArray(bytes);
return bytes;

代码示例来源:origin: codezjx/AndLinker

@Override
public void readFromParcel(Parcel in, byte[] val) {
  in.readByteArray(val);
}

代码示例来源:origin: stackoverflow.com

YourConstructor(Parcel in) {
    byte[] bytes = new byte[in.readInt()]; // read the length of the array
    in.readByteArray(bytes); // read bytes to array 
    yourBundle = deserializeBundle(bytes); // unpack the bundle
 }

代码示例来源:origin: cn.leancloud.android/avoscloud-push

public AVIMBinaryMessage(Parcel in) {
  super(in);
  int byteLen = in.readInt();
  if (byteLen <= 0) {
   this.bytes = null;
  } else {
   bytes = new byte[byteLen];
   in.readByteArray(bytes);
  }
 }
}

代码示例来源:origin: renyuneyun/Easer

private NfcTagEventData(Parcel in) {
    id = new byte[in.readInt()];
    in.readByteArray(id);
  }
}

代码示例来源:origin: baasbox/Android-SDK

public static byte[] readOptBytes(Parcel source){
  if (source.readByte()==1){
    int size = source.readInt();
    byte[] ret = new byte[size];
    source.readByteArray(ret);
    return ret;
  }
  return null;
}

代码示例来源:origin: adroitandroid/Near

private InetAddress getInetAddressFrom(Parcel in) {
  byte[] addr = new byte[in.readInt()];
  in.readByteArray(addr);
  try {
    return InetAddress.getByAddress(addr);
  } catch (UnknownHostException e) {
    e.printStackTrace();
    return null;
  }
}

代码示例来源:origin: stackoverflow.com

protected Property(final Parcel in) {
  mImage = new byte[in.readInt()]; 
  in.readByteArray(mImage); // this will read the byte array from Parcel object(in) and store the value in mImage member variable.

  mId = in.readString();

  mGeneralInformation = in.readParcelable(GeneralInformation.class.getClassLoader());
}

代码示例来源:origin: MostafaAryan/transitional-imageview

public TransitionalImage (Parcel in) {
  this.duration = in.readInt();
  this.backgroundColor= in.readInt();
  this.imageResId = in.readInt();
  int imageByteArrayLength = in.readInt();
  if(imageByteArrayLength > 0) {
    this.imageByteArray = new byte[imageByteArrayLength];
    in.readByteArray(this.imageByteArray);
  }
}

代码示例来源:origin: openxc/openxc-android

@Override
public void readFromParcel(Parcel in) {
  super.readFromParcel(in);
  mBusId = in.readInt();
  mId = in.readInt();
  in.readByteArray(mData);
}

代码示例来源:origin: openxc/openxc-android

@Override
protected void readFromParcel(Parcel in) {
  super.readFromParcel(in);
  mBusId = in.readInt();
  mId = in.readInt();
  mMode = in.readInt();
  mPid = (Integer) in.readValue(Integer.class.getClassLoader());
  int payloadSize = in.readInt();
  if(payloadSize > 0) {
    mPayload = new byte[payloadSize];
    in.readByteArray(mPayload);
  }
}

代码示例来源:origin: braintree/braintree_android

private AuthorizationRequest(Parcel source) {
  super(source);
  mPrivacyUrl = source.readString();
  mUserAgreementUrl = source.readString();
  mScopes = (HashSet) source.readSerializable();
  mAdditionalPayloadAttributes = (HashMap) source.readSerializable();
  mMsgGuid = source.readString();
  mEncryptionKey = new byte[source.readInt()];
  source.readByteArray(mEncryptionKey);
}

相关文章

Parcel类方法