Example usage for android.support.v4.app BundleCompat putBinder

List of usage examples for android.support.v4.app BundleCompat putBinder

Introduction

In this page you can find the example usage for android.support.v4.app BundleCompat putBinder.

Prototype

public static void putBinder(Bundle bundle, String key, IBinder binder) 

Source Link

Document

A convenience method to handle putting an IBinder inside a Bundle for all Android versions.

Usage

From source file:com.fondesa.lyra.coder.base.IBinderCoder.java

/**
 * Write a field's value into the saved state {@link Bundle}.
 *
 * @param state      {@link Bundle} used to save the state
 * @param key        key retrieved from {@code fieldDeclaringClass#fieldName}
 * @param fieldValue value of field// www .j  av a  2 s  .c om
 */
@Override
public void serialize(@NonNull Bundle state, @NonNull String key, @NonNull IBinder fieldValue) {
    BundleCompat.putBinder(state, key, fieldValue);
}

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

/**
 * Inserts a {@link Binder} value into an Intent as an extra.
 *
 * Uses {@link BundleCompat#putBinder()}, but doesn't throw exceptions.
 *
 * @param intent Intent to put the binder into.
 * @param name Key.//from  ww  w  . j a  va 2s .c  o  m
 * @param binder Binder object.
 */
@VisibleForTesting
public static void safePutBinderExtra(Intent intent, String name, IBinder binder) {
    if (intent == null)
        return;
    Bundle bundle = new Bundle();
    try {
        BundleCompat.putBinder(bundle, name, binder);
    } catch (Throwable t) {
        // Catches parceling exceptions.
        Log.e(TAG, "putBinder failed on bundle " + bundle);
    }
    intent.putExtras(bundle);
}