Example usage for android.view.accessibility AccessibilityEvent writeToParcel

List of usage examples for android.view.accessibility AccessibilityEvent writeToParcel

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityEvent writeToParcel.

Prototype

public void writeToParcel(Parcel parcel, int flags) 

Source Link

Usage

From source file:Main.java

/**
 * Returns a cached instance if such is available or a new one is created.
 * The returned instance is initialized from the given <code>event</code>.
 *
 * @param event The other event./*from w  w w .  j  a v a 2  s .  co  m*/
 * @return An instance.
 */
public static AccessibilityEvent obtain(AccessibilityEvent event) {
    final Parcel parcel = Parcel.obtain();

    // Write the event to the parcel and reset the data pointer.
    event.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);

    final AccessibilityEvent clone = AccessibilityEvent.CREATOR.createFromParcel(parcel);

    // Return the parcel to the global pool.
    parcel.recycle();

    return clone;
}