本文整理匯總了Java中android.os.Parcel.writeArray方法的典型用法代碼示例。如果您正苦於以下問題:Java Parcel.writeArray方法的具體用法?Java Parcel.writeArray怎麽用?Java Parcel.writeArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.os.Parcel
的用法示例。
在下文中一共展示了Parcel.writeArray方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onWriteToParcel
import android.os.Parcel; //導入方法依賴的package包/類
@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;
}
}
示例2: writeToParcel
import android.os.Parcel; //導入方法依賴的package包/類
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.age);
dest.writeLong(this.id);
dest.writeInt(this.testShort);
dest.writeByte(this.testByte);
dest.writeByte(this.testBoolean ? (byte) 1 : (byte) 0);
dest.writeFloat(this.testFloat);
dest.writeDouble(this.testDouble);
dest.writeInt(this.testChar);
dest.writeValue(this.testLONG);
dest.writeValue(this.testDOUBLE);
dest.writeSerializable(this.testCharacter);
dest.writeValue(this.testBOOLEAN);
dest.writeValue(this.testSHORT);
dest.writeString(this.name);
dest.writeParcelable(this.data, flags);
dest.writeTypedList(this.datas);
dest.writeTypedArray(this.testArrayResultData, flags);
dest.writeIntArray(this.testArrayInt);
dest.writeArray(this.testArrayInteger);
}
示例3: writeToParcel
import android.os.Parcel; //導入方法依賴的package包/類
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeArray(mArgs);
dest.writeString(mMessage);
dest.writeInt(mRessourceId);
dest.writeInt(mLevel.getInt());
dest.writeInt(mVerbosityLevel);
dest.writeLong(logtime);
}
示例4: callMethod
import android.os.Parcel; //導入方法依賴的package包/類
public void callMethod(final String className, final String serviceName,
final String methodName, final Object... paramsAndListener) {
Parcel data = Parcel.obtain();
data.writeInterfaceToken(className);
for (int i = 0; i < paramsAndListener.length - 1; i++) {
Object p = paramsAndListener[i];
if (p instanceof Byte)
data.writeByte((Byte) p);
else if (p instanceof Integer)
data.writeInt((Integer) p);
else if (p instanceof Long)
data.writeLong((Long) p);
else if (p instanceof String)
data.writeString((String) p);
else if (p instanceof Bundle)
data.writeBundle((Bundle) p);
else if (p instanceof Float)
data.writeFloat((Float) p);
else if (p instanceof FileDescriptor)
data.writeFileDescriptor((FileDescriptor) p);
else if (p instanceof List)
data.writeList((List) p);
else if (p instanceof Exception)
data.writeException((Exception) p);
else if (p instanceof IBinder)
data.writeStrongBinder((IBinder) p);
else if (p instanceof Double)
data.writeDouble((Double) p);
else if (p instanceof Map)
data.writeMap((Map) p);
else if (p instanceof boolean[])
data.writeBooleanArray((boolean[]) p);
else if (p instanceof byte[])
data.writeByteArray((byte[]) p);
else if (p instanceof char[])
data.writeCharArray((char[]) p);
else if (p instanceof int[])
data.writeIntArray((int[]) p);
else if (p instanceof IBinder[])
data.writeBinderArray((IBinder[]) p);
else if (p instanceof double[])
data.writeDoubleArray((double[]) p);
else if (p instanceof Object[])
data.writeArray((Object[]) p);
else data.writeValue(p);
}
Object lastParam = paramsAndListener[paramsAndListener.length - 1];
CallMethodResultListener listener = lastParam == null ? null :
(CallMethodResultListener) lastParam;
callMethod(className, serviceName, methodName, data, listener);
data.recycle();
}