当前位置: 首页>>代码示例>>Java>>正文


Java Parcel.marshall方法代码示例

本文整理汇总了Java中android.os.Parcel.marshall方法的典型用法代码示例。如果您正苦于以下问题:Java Parcel.marshall方法的具体用法?Java Parcel.marshall怎么用?Java Parcel.marshall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.Parcel的用法示例。


在下文中一共展示了Parcel.marshall方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testParcelling

import android.os.Parcel; //导入方法依赖的package包/类
@Test
public void testParcelling() {
    PersistableBundle bundle = new PersistableBundle();
    bundle.putString("string", "string");
    bundle.putInt("int", 0);
    bundle.putLong("long", 0);
    bundle.putBoolean("boolean", true);
    // Can't use double or any array, as the instances would be different and equals() would fail.
    Parcel parcel = Parcel.obtain();
    parcel.writeValue(bundle);
    byte[] bytes = parcel.marshall();
    parcel.recycle();
    parcel = Parcel.obtain();
    parcel.unmarshall(bytes, 0, bytes.length);
    parcel.setDataPosition(0);
    PersistableBundle parcelledBundle =
            (PersistableBundle) parcel.readValue(PersistableBundle.class.getClassLoader());

    assertEquals(bundle.toMap(1), parcelledBundle.toMap(1));
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:21,代码来源:PersistableBundleTest.java

示例2: parcelClone

import android.os.Parcel; //导入方法依赖的package包/类
public MasterSecret parcelClone() {
  Parcel thisParcel = Parcel.obtain();
  Parcel thatParcel = Parcel.obtain();
  byte[] bytes      = null;

  thisParcel.writeValue(this);
  bytes = thisParcel.marshall();

  thatParcel.unmarshall(bytes, 0, bytes.length);
  thatParcel.setDataPosition(0);

  MasterSecret that = (MasterSecret)thatParcel.readValue(MasterSecret.class.getClassLoader());

  thisParcel.recycle();
  thatParcel.recycle();

  return that;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:19,代码来源:MasterSecret.java

示例3: createResponseMap

import android.os.Parcel; //导入方法依赖的package包/类
@NonNull
private Map<String, Object> createResponseMap(Parcel reply) {
    Map<String, Object> data = new HashMap<>();
    data.put("message", "reply");
    if (reply != null) {
        try {
            byte[] marshalled = reply.marshall();
            data.put("data", marshalled);
            if (marshalled != null) {
                String base64 = BaseEncoding.base64().encode(marshalled).replace("/", "");
                data.put("data_base64", base64);
            }
        } catch (RuntimeException e) {
            data.put("info", "activeObject");
        }
    }
    return data;
}
 
开发者ID:mateuszk87,项目名称:BadIntent,代码行数:19,代码来源:RestAPI.java

示例4: save

import android.os.Parcel; //导入方法依赖的package包/类
/**
 * Saves the repeatable intent (useful for later cancelling an alarm after the application has restarted)
 *
 * @param siteToSiteRepeatableIntent the repeatable intent
 */
public void save(SiteToSiteRepeatableIntent siteToSiteRepeatableIntent) {
    Parcel parcel = Parcel.obtain();
    siteToSiteRepeatableIntent.getIntent().writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    byte[] bytes = parcel.marshall();
    SQLiteDatabase writableDatabase = sqLiteOpenHelper.getWritableDatabase();
    try {
        ContentValues contentValues = new ContentValues();
        contentValues.put(PENDING_INTENT_REQUEST_CODE, siteToSiteRepeatableIntent.getRequestCode());
        contentValues.put(CONTENT_COLUMN, bytes);
        writableDatabase.insertOrThrow(PENDING_INTENT_TABLE_NAME, null, contentValues);
    } finally {
        writableDatabase.close();
    }
}
 
开发者ID:hortonworks,项目名称:nifi-android-s2s,代码行数:21,代码来源:DemoAppDB.java

示例5: marshall

import android.os.Parcel; //导入方法依赖的package包/类
public static byte[] marshall(Parcelable parceable) {
    Parcel parcel = Parcel.obtain();
    parceable.writeToParcel(parcel, 0);
    byte[] bytes = parcel.marshall();
    parcel.recycle();
    return bytes;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:8,代码来源:ParcelableUtil.java

示例6: parcelable2Bytes

import android.os.Parcel; //导入方法依赖的package包/类
private static byte[] parcelable2Bytes(final Parcelable parcelable) {
    if (parcelable == null) return null;
    Parcel parcel = Parcel.obtain();
    parcelable.writeToParcel(parcel, 0);
    byte[] bytes = parcel.marshall();
    parcel.recycle();
    return bytes;
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:9,代码来源:CacheUtils.java

示例7: serialize

import android.os.Parcel; //导入方法依赖的package包/类
public static byte[] serialize(Parcelable parceable) {
  Parcel parcel = Parcel.obtain();
  parceable.writeToParcel(parcel, 0);
  byte[] bytes = parcel.marshall();
  parcel.recycle();
  return bytes;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:8,代码来源:ParcelUtil.java

示例8: marshall

import android.os.Parcel; //导入方法依赖的package包/类
static byte[] marshall(Object o) {
    Parcel parcel = Parcel.obtain();
    parcel.writeValue(o);
    byte[] result = parcel.marshall();
    parcel.recycle();
    return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:ParcelFn.java

示例9: parcelableToByteArray

import android.os.Parcel; //导入方法依赖的package包/类
private <T extends Parcelable> byte[] parcelableToByteArray(T parcelable) {
    Parcel parcel = Parcel.obtain();
    parcel.writeParcelable(parcelable, 0);
    byte[] data = parcel.marshall();
    parcel.recycle();
    return data;
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:8,代码来源:JobStore.java

示例10: clone

import android.os.Parcel; //导入方法依赖的package包/类
public RecordFood clone() {
    Parcel parcel = Parcel.obtain();
    writeToParcel(parcel, 0);
    byte[] bytes = parcel.marshall();
    Parcel parcel2 = Parcel.obtain();
    parcel2.unmarshall(bytes, 0, bytes.length);
    parcel2.setDataPosition(0);
    return (RecordFood) CREATOR.createFromParcel(parcel2);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:RecordFood.java

示例11: marshallRequest

import android.os.Parcel; //导入方法依赖的package包/类
private byte[] marshallRequest(int token, byte data[]) {
    Parcel p = Parcel.obtain();
    p.writeInt(RIL_REQUEST_OEM_RAW);
    p.writeInt(token);
    p.writeByteArray(data);
    byte[] res = p.marshall();
    p.recycle();
    return res;
}
 
开发者ID:5GSD,项目名称:AIMSICDL,代码行数:10,代码来源:SamsungMulticlientRilExecutor.java

示例12: parcelable2Bytes

import android.os.Parcel; //导入方法依赖的package包/类
private static byte[] parcelable2Bytes(Parcelable parcelable) {
    if (parcelable == null) return null;
    Parcel parcel = Parcel.obtain();
    parcelable.writeToParcel(parcel, 0);
    byte[] bytes = parcel.marshall();
    parcel.recycle();
    return bytes;
}
 
开发者ID:pan2yong22,项目名称:AndroidUtilCode-master,代码行数:9,代码来源:CacheUtils.java

示例13: marshallParcelable

import android.os.Parcel; //导入方法依赖的package包/类
/**
 * Marshalls a parcelable into a byte array
 *
 * @param parcelable the parcelable
 * @param <T>        the type
 * @return the byte array
 */
public static <T extends Parcelable> byte[] marshallParcelable(T parcelable) {
    if (parcelable == null) {
        return null;
    }
    Parcel parcel = Parcel.obtain();
    parcelable.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    try {
        return parcel.marshall();
    } finally {
        parcel.recycle();
    }
}
 
开发者ID:hortonworks,项目名称:nifi-android-s2s,代码行数:21,代码来源:SerializationUtils.java

示例14: marshallSerializable

import android.os.Parcel; //导入方法依赖的package包/类
/**
 * Marshalls a serializable into a byte array
 *
 * @param serializable the serializable
 * @param <T>          the type
 * @return the byte array
 */
public static <T extends Serializable> byte[] marshallSerializable(T serializable) {
    if (serializable == null) {
        return null;
    }
    Parcel parcel = Parcel.obtain();
    parcel.writeSerializable(serializable);
    parcel.setDataPosition(0);
    try {
        return parcel.marshall();
    } finally {
        parcel.recycle();
    }
}
 
开发者ID:hortonworks,项目名称:nifi-android-s2s,代码行数:21,代码来源:SerializationUtils.java

示例15: onSaveInstanceState

import android.os.Parcel; //导入方法依赖的package包/类
public void onSaveInstanceState(Bundle outState) {
    Parcel outParcel = Parcel.obtain();
    outParcel.writeSparseBooleanArray(mCheckStates);
    final int numStates = mCheckedIdStates.size();
    outParcel.writeInt(numStates);
    for (int i=0; i<numStates; i++) {
        outParcel.writeLong(mCheckedIdStates.keyAt(i));
        outParcel.writeInt(mCheckedIdStates.valueAt(i));
    }
    byte[] states = outParcel.marshall();
    outState.putByteArray(SELECTED_ITEMS_KEY, states);
    outParcel.recycle();
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:14,代码来源:ItemChoiceManager.java


注:本文中的android.os.Parcel.marshall方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。