當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。