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

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

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

Parcel.writeMap介绍

[英]Please use #writeBundle instead. Flattens a Map into the parcel at the current dataPosition(), growing dataCapacity() if needed. The Map keys must be String objects. The Map values are written using #writeValue and must follow the specification there.

It is strongly recommended to use #writeBundle instead of this method, since the Bundle class provides a type-safe API that allows you to avoid mysterious type errors at the point of marshalling.
[中]请改用#writeBundle。将地图展平到当前dataPosition()处的地块中,必要时增加dataCapacity()。贴图键必须是字符串对象。映射值是使用#writeValue编写的,必须遵循那里的规范。
强烈建议使用#writeBundle而不是此方法,因为Bundle类提供了一个类型安全API,允许您在编组时避免出现神秘的类型错误。

代码示例

代码示例来源:origin: lingochamp/FileDownloader

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeMap(mHeaderMap);
}

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

@Override
public void writePersistenceData(Parcel p) {
  final SparseArray<HashMap<String, VSConfig>> configs = mService.getConfigs();
  int N = configs.size();
  p.writeInt(N);
  while (N-- > 0) {
    int userId = configs.keyAt(N);
    Map<String, VSConfig> userMap = configs.valueAt(N);
    p.writeInt(userId);
    p.writeMap(userMap);
  }
}

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

public static void writeMeta(Parcel p, Bundle meta) {
  Map<String, String> map = new HashMap<>();
  if (meta != null) {
    for (String key : meta.keySet()) {
      map.put(key, meta.getString(key));
    }
  }
  p.writeMap(map);
}

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

@Override
public void writePersistenceData(Parcel p) {
  mGlobalConfig.writeToParcel(p, 0);
  p.writeInt(mLocConfigs.size());
  for (int i = 0; i < mLocConfigs.size(); i++) {
    int userId = mLocConfigs.keyAt(i);
    Map<String, VLocConfig> pkgs = mLocConfigs.valueAt(i);
    p.writeInt(userId);
    p.writeMap(pkgs);
  }
}

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

@Test
public void testReadWriteMap() throws Exception {
 HashMap<String, String> original = new HashMap<>();
 original.put("key", "value");
 parcel.writeMap(original);
 parcel.setDataPosition(0);
 HashMap<String, String> rehydrated = parcel.readHashMap(null);
 assertEquals("value", rehydrated.get("key"));
}

代码示例来源:origin: GrassQing/CommonPrintProvider

@Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeMap(this.mMap);
  }
}

代码示例来源:origin: com.harium.android/core

@SuppressWarnings("deprecation")
public void writeToParcel(Parcel parcel, int flags) {
  parcel.writeMap(mValues);
}

代码示例来源:origin: Countly/countly-sdk-android

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeMap(data);
  Log.d("Countly", "written: " + data.get(KEY_ID));
}

代码示例来源:origin: flipkart-incubator/proteus

/**
 * Flatten this object in to a Parcel.
 *
 * @param dest  The Parcel in which the object should be written.
 * @param flags Additional flags about how the object should be written.
 *              May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}.
 */
@Override
public void writeToParcel(Parcel dest, int flags) {
 dest.writeInt(sNextGeneratedId.get());
 dest.writeMap(idMap);
}

代码示例来源:origin: bilibili/BiliShare

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeString(mTitle);
  dest.writeString(mContent);
  dest.writeString(mTargetUrl);
  try {
    dest.writeMap(mExtraMap);
  } catch (Exception e) {
    e.printStackTrace();
  }
}

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

@Override
public void writeToParcel(Parcel parcel, int i) {
 parcel.writeParcelable(duration, PARCELABLE_WRITE_RETURN_VALUE);
 parcel.writeMap(attributes);
 parcel.writeString(eventName);
 parcel.writeString(labelName);
 parcel.writeString(primaryKey);
 parcel.writeInt(accumulation);
}

代码示例来源:origin: NordicSemiconductor/Android-nRF-Mesh-Library

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeByteArray(elementAddress);
  dest.writeInt(locationDescriptor);
  dest.writeMap(meshModels);
}

代码示例来源:origin: JumeiRdGroup/Router

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeString(name);
  dest.writeMap(params);
  dest.writeInt(type);
  dest.writeBundle(extra);
}

代码示例来源:origin: bzsome/VirtualApp-x326

@Override
public void writePersistenceData(Parcel p) {
  final SparseArray<HashMap<String, VSConfig>> configs = mService.getConfigs();
  int N = configs.size();
  p.writeInt(N);
  while (N-- > 0) {
    int userId = configs.keyAt(N);
    Map<String, VSConfig> userMap = configs.valueAt(N);
    p.writeInt(userId);
    p.writeMap(userMap);
  }
}

代码示例来源:origin: laizimo/richeditor

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeSerializable(this.pathRecord);
  dest.writeParcelable(this.menuItemTree, flags);
  dest.writeMap(this.bottomMenuItems);
}

代码示例来源:origin: darkskygit/VirtualApp

public static void writeMeta(Parcel p, Bundle meta) {
  Map<String, String> map = new HashMap<>();
  if (meta != null) {
    for (String key : meta.keySet()) {
      map.put(key, meta.getString(key));
    }
  }
  p.writeMap(map);
}

代码示例来源:origin: bzsome/VirtualApp-x326

public static void writeMeta(Parcel p, Bundle meta) {
  Map<String, String> map = new HashMap<>();
  if (meta != null) {
    for (String key : meta.keySet()) {
      map.put(key, meta.getString(key));
    }
  }
  p.writeMap(map);
}

代码示例来源:origin: com.google.android.apps.common.testing.accessibility.framework/accessibility-test-framework

@Override
public void writeToParcel(Parcel dest, int flags) {
  dest.writeString(mName);
  dest.writeMap(mLuminanceMap);
  dest.writeMap(mLuminanceHistogram);
  dest.writeList(mBackgroundColors);
  dest.writeList(mForegroundColors);
  dest.writeDouble(mBackgroundLuminance);
  dest.writeDouble(mForegroundLuminance);
  dest.writeValue(mScreenBounds);
  dest.writeDouble(mContrastRatio);
}

代码示例来源:origin: darkskygit/VirtualApp

@Override
public void writePersistenceData(Parcel p) {
  mGlobalConfig.writeToParcel(p, 0);
  p.writeInt(mLocConfigs.size());
  for (int i = 0; i < mLocConfigs.size(); i++) {
    int userId = mLocConfigs.keyAt(i);
    Map<String, VLocConfig> pkgs = mLocConfigs.valueAt(i);
    p.writeInt(userId);
    p.writeMap(pkgs);
  }
}

代码示例来源:origin: bzsome/VirtualApp-x326

@Override
public void writePersistenceData(Parcel p) {
  mGlobalConfig.writeToParcel(p, 0);
  p.writeInt(mLocConfigs.size());
  for (int i = 0; i < mLocConfigs.size(); i++) {
    int userId = mLocConfigs.keyAt(i);
    Map<String, VLocConfig> pkgs = mLocConfigs.valueAt(i);
    p.writeInt(userId);
    p.writeMap(pkgs);
  }
}

相关文章

Parcel类方法