本文整理了Java中android.os.Parcel.writeValue()
方法的一些代码示例,展示了Parcel.writeValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parcel.writeValue()
方法的具体详情如下:
包路径:android.os.Parcel
类名称:Parcel
方法名:writeValue
[英]Flatten a generic object in to a parcel. The given Object value may currently be one of the following types:
Parcelable objects are written with Parcelable#writeToParcel using contextual flags of 0. When serializing objects containing ParcelFileDescriptors, this may result in file descriptor leaks when they are returned from Binder calls (where Parcelable#PARCELABLE_WRITE_RETURN_VALUE should be used).
[中]将常规对象展平到地块中。给定的对象值当前可能是以下类型之一:
*空的
*串
*字节
*短的
*整数
*长的
*漂浮
*加倍
*布尔值
*字符串[]
*布尔[]
*字节[]
*int[]
*长[]
*对象[](支持此处定义的相同类型的对象)。
*捆
*映射(由#writeMap支持)。
*实现可包裹协议的任何对象。
*可包裹的
*CharSequence(由TextUtils#writeToParcel支持)。
*列表(由#writeList支持)。
*SparseArray(由#writeSparseArray(SparseArray))支持)。
*伊宾德
*任何实现Serializable的对象(但有关注意事项,请参见#writeSerializable)。请注意,前面的所有类型都有相对高效的实现来写入包裹;必须依赖泛型序列化方法的效率要低得多,应该尽可能避免。
Parcelable对象使用Parcelable#writeToParcel写入,使用上下文标志0。序列化包含ParcelFileDescriptor的对象时,如果从绑定器调用返回文件描述符(其中应使用Parcelable#Parcelable _WRITE _RETURN _值),可能会导致文件描述符泄漏。
代码示例来源:origin: rey5137/material
@Override
public void writeToParcel(@NonNull Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeValue(mode);
out.writeValue(hour);
out.writeValue(minute);
out.writeValue(is24Hour ? 1 : 0);
}
代码示例来源:origin: rey5137/material
@Override
public void writeToParcel(@NonNull Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeValue(yearMin);
out.writeValue(yearMax);
out.writeValue(year);
}
代码示例来源:origin: rey5137/material
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mStyleId);
dest.writeInt(mContentViewId);
dest.writeValue(mTitle);
dest.writeValue(mPositive);
dest.writeValue(mNegative);
dest.writeValue(mNeutral);
onWriteToParcel(dest, flags);
}
代码示例来源:origin: ZieIony/Carbon
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeValue(checked);
}
代码示例来源:origin: rey5137/material
@Override
public void writeToParcel(@NonNull Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeValue(checked);
}
代码示例来源:origin: seven332/EhViewer
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeString(mSerializedPattern);
dest.writeInt(mDisplayMode);
dest.writeValue(mInputEnabled);
dest.writeValue(mInStealthMode);
dest.writeValue(mTactileFeedbackEnabled);
}
代码示例来源:origin: naman14/Timber
@Override
public void writeToParcel(@NonNull Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeValue(played);
}
}
代码示例来源:origin: stackoverflow.com
dest.writeValue(str);
代码示例来源:origin: nickbutcher/plaid
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(text);
dest.writeFloat(textSize);
dest.writeInt(textColor);
dest.writeValue(bounds);
dest.writeInt(fontResId);
dest.writeFloat(lineSpacingAdd);
dest.writeFloat(lineSpacingMult);
dest.writeValue(textPosition);
dest.writeInt(textHeight);
dest.writeInt(textWidth);
dest.writeInt(breakStrategy);
dest.writeFloat(letterSpacing);
dest.writeInt(maxLines);
}
代码示例来源:origin: facebook/facebook-android-sdk
private static String encodeUserInfo(UserInfo userInfo) {
Parcel parcel = Parcel.obtain();
parcel.writeValue(userInfo);
byte[] data = parcel.marshall();
parcel.recycle();
return Base64.encodeToString(data, Base64.DEFAULT);
}
}
代码示例来源:origin: rey5137/material
@Override
protected void onWriteToParcel(Parcel dest, int flags) {
dest.writeInt(mMode);
switch (mMode){
case MODE_MESSAGE:
dest.writeValue(mMessage);
break;
case MODE_ITEMS:
dest.writeArray(mItems);
dest.writeInt(mSelectedIndexes == null ? 0 : mSelectedIndexes[0]);
break;
case MODE_MULTI_ITEMS:
dest.writeArray(mItems);
int length = mSelectedIndexes == null ? 0 : mSelectedIndexes.length;
dest.writeInt(length);
if(length > 0)
dest.writeIntArray(mSelectedIndexes);
break;
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(size());
for (int i=0;i<size();i++) {
dest.writeInt(keyAt(i));
dest.writeValue(valueAt(i));
}
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(size());
for (int i=0;i<size();i++) {
dest.writeInt(keyAt(i));
dest.writeValue(valueAt(i));
}
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(size());
for (int i=0;i<size();i++) {
dest.writeInt(keyAt(i));
dest.writeValue(valueAt(i));
}
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(size());
for (int i=0;i<size();i++) {
dest.writeInt(keyAt(i));
dest.writeValue(valueAt(i));
}
}
}
代码示例来源:origin: konmik/nucleus
return null;
}).when(parcel).writeValue(any());
代码示例来源:origin: AltBeacon/android-beacon-library
out.writeString(mParserIdentifier);
out.writeByte((byte) (mMultiFrameBeacon ? 1: 0));
out.writeValue(mRunningAverageRssi);
out.writeInt(mRssiMeasurementCount);
out.writeInt(mPacketCount);
代码示例来源:origin: konmik/nucleus
static byte[] marshall(Object o) {
Parcel parcel = Parcel.obtain();
parcel.writeValue(o);
byte[] result = parcel.marshall();
parcel.recycle();
return result;
}
}
代码示例来源:origin: oasisfeng/condom
@Override protected boolean onTransact(final int code, final Parcel data, final Parcel reply, final int flags) throws RemoteException {
try {
final Class<?> clazz = Class.forName(data.readString());
final Constructor<?> constructor = clazz.getDeclaredConstructors()[0];
constructor.setAccessible(true);
final Class<?>[] parameter_types = constructor.getParameterTypes();
final Object[] args = new Object[parameter_types.length];
for (int i = 0; i < args.length; i++) {
if (parameter_types[i] == Context.class) args[i] = TestService.this;
else if (parameter_types[i] == Application.class) args[i] = getApplication();
else args[i] = data.readValue(getClassLoader());
}
final Procedure procedure = (Procedure) constructor.newInstance(args);
procedure.run(TestService.this);
reply.writeValue(null);
} catch (final Throwable t) {
reply.writeValue(t);
}
return true;
}
};
代码示例来源:origin: oasisfeng/condom
if (type == enclosing_class || type == Context.class || type == Application.class) data.writeValue(null);
else try {
data.writeValue(value);
} catch (final RuntimeException e) {
throw new RuntimeException("Invalid lambda parameter type: " + value.getClass().getCanonicalName(), e);
内容来源于网络,如有侵权,请联系作者删除!