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

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

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

Parcel.readString介绍

[英]Read a string value from the parcel at the current dataPosition().
[中]从当前dataPosition()处的地块读取字符串值。

代码示例

代码示例来源:origin: aa112901/remusic

protected SearchAlbumInfo(Parcel in) {
  this.album_id = in.readString();
  this.author = in.readString();
  this.hot = in.readInt();
  this.title = in.readString();
  this.artist_id = in.readString();
  this.all_artist_id = in.readString();
  this.company = in.readString();
  this.publishtime = in.readString();
  this.album_desc = in.readString();
  this.pic_small = in.readString();
}

代码示例来源:origin: smuyyh/BookReader

public SavedState(Parcel source) {
  super(source);
  tagCount = source.readInt();
  tags = new String[tagCount];
  source.readStringArray(tags);
  checkedPosition = source.readInt();
  input = source.readString();
}

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

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeParcelable(otherClass, flags);
  dest.writeString(name);
  dest.writeInt(id);
}

private MyClass(Parcel in) {
  otherClass = (OtherClass) in.readParcelable(OtherClass.class.getClassLoader());
  name = in.readString();
  id = in.readInt();
}

代码示例来源:origin: robolectric/robolectric

@Override
 protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
  this.code = code;
  this.data = data;
  this.reply = reply;
  this.flags = flags;
  String string = data.readString();
  reply.writeNoException();
  reply.writeString(string);
  return true;
 }
}

代码示例来源:origin: android10/Android-CleanArchitecture

private SavedState(Parcel in) {
 super(in);
 this.imagePlaceHolderResId = in.readInt();
 this.imageUrl = in.readString();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testReadWriteMultipleStrings() {
 for (int i = 0; i < 10; ++i) {
  parcel.writeString(Integer.toString(i));
  assertInvariants();
 }
 parcel.setDataPosition(0);
 for (int i = 0; i < 10; ++i) {
  assertThat(parcel.readString()).isEqualTo(Integer.toString(i));
 }
 // now try to read past the number of items written and see what happens
 assertThat(parcel.readString()).isNull();
}

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

public void writeToParcel(Parcel out, int flags) {
  out.writeString(_mac);
  out.writeString(_pan);
  out.writeInt(_band);
  out.writeSerializable(_lqis);
  out.writeTypedList(_devices);
}

private ZigBeeNetwork(Parcel in) {
  _mac = in.readString();
  _pan = in.readString();
  _band = in.readInt();
  _lqis = (ArrayList<Integer>) in.readSerializable();
  in.readTypedList(_devices, ZigBeeDev.CREATOR);
}

代码示例来源:origin: aa112901/remusic

protected SearchArtistInfo(Parcel in) {
  this.artist_id = in.readString();
  this.author = in.readString();
  this.ting_uid = in.readString();
  this.avatar_middle = in.readString();
  this.album_num = in.readInt();
  this.song_num = in.readInt();
  this.country = in.readString();
  this.artist_desc = in.readString();
  this.artist_source = in.readString();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testReadWriteStringLong() {
 for (long i = 0; i < 10; ++i) {
  parcel.writeString(Long.toString(i));
  parcel.writeLong(i);
 }
 parcel.setDataPosition(0);
 for (long i = 0; i < 10; ++i) {
  assertThat(parcel.readString()).isEqualTo(Long.toString(i));
  assertThat(parcel.readLong()).isEqualTo(i);
 }
 // now try to read past the number of items written and see what happens
 assertThat(parcel.readString()).isNull();
 assertThat(parcel.readLong()).isEqualTo(0L);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testReadWriteStringInt() {
 for (int i = 0; i < 10; ++i) {
  parcel.writeString(Integer.toString(i));
  parcel.writeInt(i);
 }
 parcel.setDataPosition(0);
 for (int i = 0; i < 10; ++i) {
  assertThat(parcel.readString()).isEqualTo(Integer.toString(i));
  assertThat(parcel.readInt()).isEqualTo(i);
 }
 // now try to read past the number of items written and see what happens
 assertThat(parcel.readString()).isNull();
 assertThat(parcel.readInt()).isEqualTo(0);
}

代码示例来源:origin: Justson/AgentWeb

protected FileParcel(Parcel in) {
  mId = in.readInt();
  mContentPath = in.readString();
  mFileBase64 = in.readString();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testWriteNullString() {
 parcel.writeString(null);
 parcel.setDataPosition(0);
 assertThat(parcel.readString()).isNull();
 assertThat(parcel.dataPosition()).isEqualTo(4);
}

代码示例来源:origin: bumptech/glide

private MediaStoreData(Parcel in) {
 rowId = in.readLong();
 uri = Uri.parse(in.readString());
 mimeType = in.readString();
 dateTaken = in.readLong();
 dateModified = in.readLong();
 orientation = in.readInt();
 type = Type.valueOf(in.readString());
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testSetDataPositionToEmptyString() {
 parcel.writeString("");
 parcel.setDataPosition(parcel.dataPosition());
 parcel.writeString("something else");
 parcel.setDataPosition(0);
 assertThat(parcel.readString()).isEmpty();
}

代码示例来源:origin: android-hacker/VirtualXposed

protected InstalledAppInfo(Parcel in) {
  this.packageName = in.readString();
  this.apkPath = in.readString();
  this.libPath = in.readString();
  this.dependSystem = in.readByte() != 0;
  this.appId = in.readInt();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testInvalidReadFromOverwrittenObject() {
 parcel.writeString("hello all");
 parcel.setDataPosition(4);
 parcel.writeInt(5);
 parcel.setDataPosition(0);
 try {
  parcel.readString();
  fail("should have thrown UnreliableBehaviorError");
 } catch (UnreliableBehaviorError e) {
  assertThat(e)
    .hasMessage(
      "Looking for String at position 0, found String [hello all] taking 24 bytes, but "
        + "[5] interrupts it at position 4");
 }
}

代码示例来源:origin: googlesamples/easypermissions

private AppSettingsDialog(Parcel in) {
  mThemeResId = in.readInt();
  mRationale = in.readString();
  mTitle = in.readString();
  mPositiveButtonText = in.readString();
  mNegativeButtonText = in.readString();
  mRequestCode = in.readInt();
  mIntentFlags = in.readInt();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testReadWriteSingleStringEvenLength() {
 String val = "test";
 parcel.writeString(val);
 parcel.setDataPosition(0);
 assertThat(parcel.readString()).isEqualTo(val);
 assertWithMessage("4B length + 4*2B data + 2B null char + 2B padding")
   .that(parcel.dataSize())
   .isEqualTo(16);
}

代码示例来源:origin: JackyAndroid/AndroidTVLauncher

protected MediaModel(Parcel in) {
  id = in.readInt();
  title = in.readString();
  content = in.readString();
  imageUrl = in.readString();
  videoUrl = in.readString();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testWriteEmptyString() {
 parcel.writeString("");
 parcel.setDataPosition(0);
 assertThat(parcel.readString()).isEmpty();
 assertWithMessage("4B length + 2B null char + 2B padding").that(parcel.dataSize()).isEqualTo(8);
}

相关文章

Parcel类方法