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

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

Introduction

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

Prototype

public static IBinder getBinder(Bundle bundle, String key) 

Source Link

Document

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

Usage

From source file:com.ferdi2005.secondgram.support.customtabs.CustomTabsSessionToken.java

public static CustomTabsSessionToken getSessionTokenFromIntent(Intent intent) {
    Bundle b = intent.getExtras();//from   w ww . j a  va 2 s.c o  m
    IBinder binder = BundleCompat.getBinder(b, "android.support.customtabs.extra.SESSION");
    return binder == null ? null : new CustomTabsSessionToken(ICustomTabsCallback.Stub.asInterface(binder));
}

From source file:android.support.customtabs.CustomTabsSessionToken.java

/**
 * Obtain a {@link CustomTabsSessionToken} from an intent. See {@link CustomTabsIntent.Builder}
 * for ways to generate an intent for custom tabs.
 * @param intent The intent to generate the token from. This has to include an extra for
 *               {@link CustomTabsIntent#EXTRA_SESSION}.
 * @return The token that was generated.
 *//*from   www.j av  a 2s  .  c  o  m*/
public static CustomTabsSessionToken getSessionTokenFromIntent(Intent intent) {
    Bundle b = intent.getExtras();
    IBinder binder = BundleCompat.getBinder(b, CustomTabsIntent.EXTRA_SESSION);
    if (binder == null)
        return null;
    return new CustomTabsSessionToken(ICustomTabsCallback.Stub.asInterface(binder));
}

From source file:com.toan_itc.tn.CustomTabClient.CustomTabsSessionToken.java

/**
 * Obtain a {@link CustomTabsSessionToken} from an intent. See {@link android.support.customtabs.CustomTabsIntent.Builder}
 * for ways to generate an intent for custom tabs.
 * @param intent The intent to generate the token from. This has to include an extra for
 *               {@link android.support.customtabs.CustomTabsIntent#EXTRA_SESSION}.
 * @return The token that was generated.
 *///w  w  w.j a v  a2  s .  c  om
public static CustomTabsSessionToken getSessionTokenFromIntent(Intent intent) {
    Bundle b = intent.getExtras();
    IBinder binder = BundleCompat.getBinder(b, android.support.customtabs.CustomTabsIntent.EXTRA_SESSION);
    if (binder == null)
        return null;
    return new CustomTabsSessionToken(ICustomTabsCallback.Stub.asInterface(binder));
}

From source file:android.support.customtabs.TrustedWebUtils.java

/**
 * Launch the given {@link CustomTabsIntent} as a Trusted Web Activity. The given
 * {@link CustomTabsIntent} should have a valid {@link CustomTabsSession} associated with it
 * during construction. Once the Trusted Web Activity is launched, browser side implementations
 * may have their own fallback behavior (e.g. Showing the page in a custom tab UI with toolbar)
 * based on qualifications listed above or more.
 *
 * @param context {@link Context} to use while launching the {@link CustomTabsIntent}.
 * @param customTabsIntent The {@link CustomTabsIntent} to use for launching the
 *                         Trusted Web Activity. Note that all customizations in the given
 *                         associated with browser toolbar controls will be ignored.
 * @param uri The web page to launch as Trusted Web Activity.
 *///from  w w w . j a va 2s  . c o m
public static void launchAsTrustedWebActivity(@NonNull Context context,
        @NonNull CustomTabsIntent customTabsIntent, @NonNull Uri uri) {
    if (BundleCompat.getBinder(customTabsIntent.intent.getExtras(), CustomTabsIntent.EXTRA_SESSION) == null) {
        throw new IllegalArgumentException(
                "Given CustomTabsIntent should be associated with a valid CustomTabsSession");
    }
    customTabsIntent.intent.putExtra(EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY, true);
    customTabsIntent.launchUrl(context, uri);
}

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

/**
 * Just like {@link BundleCompat#getBinder()}, but doesn't throw exceptions.
 *///from w w  w . ja v  a2  s  . c  o m
public static IBinder safeGetBinder(Bundle bundle, String name) {
    if (bundle == null)
        return null;
    try {
        return BundleCompat.getBinder(bundle, name);
    } catch (Throwable t) {
        // Catches un-parceling exceptions.
        Log.e(TAG, "getBinder failed on bundle " + bundle);
        return null;
    }
}