Example usage for android.content Intent writeToParcel

List of usage examples for android.content Intent writeToParcel

Introduction

In this page you can find the example usage for android.content Intent writeToParcel.

Prototype

public void writeToParcel(Parcel out, int flags) 

Source Link

Usage

From source file:Main.java

public static byte[] toByteArray(Intent intent) {
    Parcel obtain = Parcel.obtain();//from   www  . jav  a2  s.  c o m
    intent.writeToParcel(obtain, 0);
    byte[] byteArray = obtain.marshall();
    obtain.recycle();
    return byteArray;
}

From source file:org.chromium.chrome.browser.util.IntentUtils.java

/**
 * Returns how large the Intent will be in Parcel form, which is helpful for gauging whether
 * Android will deliver the Intent instead of throwing a TransactionTooLargeException.
 *
 * @param intent Intent to get the size of.
 * @return Number of bytes required to parcel the Intent.
 *//*from   w ww .  j  av  a 2  s  .c o m*/
public static int getParceledIntentSize(Intent intent) {
    Parcel parcel = Parcel.obtain();
    intent.writeToParcel(parcel, 0);
    return parcel.dataSize();
}