Java Code Examples for android.support.v4.app.BundleCompat

The following are top voted examples for showing how to use android.support.v4.app.BundleCompat. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: letv   File: MediaBrowserCompat.java   View source code 6 votes vote down vote up
public void onConnected() {
    Bundle extras = MediaBrowserCompatApi21.getExtras(this.mBrowserObj);
    if (extras != null) {
        IBinder serviceBinder = BundleCompat.getBinder(extras, MediaBrowserProtocol.EXTRA_MESSENGER_BINDER);
        if (serviceBinder != null) {
            this.mServiceBinderWrapper = new ServiceBinderWrapper(serviceBinder);
            this.mCallbacksMessenger = new Messenger(this.mHandler);
            this.mHandler.setCallbacksMessenger(this.mCallbacksMessenger);
            try {
                this.mServiceBinderWrapper.registerCallbackMessenger(this.mCallbacksMessenger);
            } catch (RemoteException e) {
                Log.i(MediaBrowserCompat.TAG, "Remote error registering client messenger.");
            }
            onServiceConnected(this.mCallbacksMessenger, null, null, null);
        }
    }
}
 
Example 2
Project: boohee_v5.6   File: MediaBrowserCompat.java   View source code 6 votes vote down vote up
public void onConnected() {
    Bundle extras = MediaBrowserCompatApi21.getExtras(this.mBrowserObj);
    if (extras != null) {
        IBinder serviceBinder = BundleCompat.getBinder(extras, MediaBrowserProtocol.EXTRA_MESSENGER_BINDER);
        if (serviceBinder != null) {
            this.mServiceBinderWrapper = new ServiceBinderWrapper(serviceBinder);
            this.mCallbacksMessenger = new Messenger(this.mHandler);
            this.mHandler.setCallbacksMessenger(this.mCallbacksMessenger);
            try {
                this.mServiceBinderWrapper.registerCallbackMessenger(this.mCallbacksMessenger);
            } catch (RemoteException e) {
                Log.i(MediaBrowserCompat.TAG, "Remote error registering client messenger.");
            }
            onServiceConnected(this.mCallbacksMessenger, null, null, null);
        }
    }
}
 
Example 3
Project: airgram   File: CustomTabsIntent.java   View source code 5 votes vote down vote up
public Builder(@Nullable CustomTabsSession session) {
    this.mIntent = new Intent("android.intent.action.VIEW");
    this.mMenuItems = null;
    this.mStartAnimationBundle = null;
    this.mActionButtons = null;
    if (session != null) {
        this.mIntent.setPackage(session.getComponentName().getPackageName());
    }

    Bundle bundle = new Bundle();
    BundleCompat.putBinder(bundle, "android.support.customtabs.extra.SESSION", session == null ? null : session.getBinder());
    this.mIntent.putExtras(bundle);
}
 
Example 4
Project: chromium-for-android-56-debug-video   File: IntentUtils.java   View source code 5 votes vote down vote up
/**
 * Just like {@link BundleCompat#getBinder()}, but doesn't throw exceptions.
 */
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;
    }
}
 
Example 5
Project: chromium-for-android-56-debug-video   File: IntentUtils.java   View source code 5 votes vote down vote up
/**
 * 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.
 * @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);
}
 
Example 6
Project: PlusGram   File: CustomTabsIntent.java   View source code 5 votes vote down vote up
public Builder(@Nullable CustomTabsSession session) {
    this.mIntent = new Intent("android.intent.action.VIEW");
    this.mMenuItems = null;
    this.mStartAnimationBundle = null;
    this.mActionButtons = null;
    if (session != null) {
        this.mIntent.setPackage(session.getComponentName().getPackageName());
    }

    Bundle bundle = new Bundle();
    BundleCompat.putBinder(bundle, "android.support.customtabs.extra.SESSION", session == null ? null : session.getBinder());
    this.mIntent.putExtras(bundle);
}
 
Example 7
Project: AndroidChromium   File: IntentUtils.java   View source code 5 votes vote down vote up
/**
 * Just like {@link BundleCompat#getBinder()}, but doesn't throw exceptions.
 */
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;
    }
}
 
Example 8
Project: AndroidChromium   File: IntentUtils.java   View source code 5 votes vote down vote up
/**
 * 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.
 * @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);
}
 
Example 9
Project: S1-Next   File: IntentUtil.java   View source code 5 votes vote down vote up
public static void putCustomTabsExtra(Intent intent) {
    // enable Custom Tabs if supported
    Bundle bundle = new Bundle();
    BundleCompat.putBinder(bundle, EXTRA_CUSTOM_TABS_SESSION, null);
    intent.putExtras(bundle);
    intent.putExtra(EXTRA_ENABLE_URLBAR_HIDING, true);
}
 
Example 10
Project: S1-Next   File: IntentUtil.java   View source code 5 votes vote down vote up
private static void putCustomTabsExtra(List<Intent> intentList) {
    // enable Custom Tabs if supported
    Bundle bundle = new Bundle();
    BundleCompat.putBinder(bundle, EXTRA_CUSTOM_TABS_SESSION, null);
    for (Intent intent : intentList) {
        intent.putExtras(bundle);
        intent.putExtra(EXTRA_ENABLE_URLBAR_HIDING, true);
    }
}
 
Example 11
Project: 365browser   File: IntentUtils.java   View source code 5 votes vote down vote up
/**
 * Just like {@link BundleCompat#getBinder()}, but doesn't throw exceptions.
 */
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;
    }
}
 
Example 12
Project: 365browser   File: IntentUtils.java   View source code 5 votes vote down vote up
/**
 * 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.
 * @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);
}
 
Example 13
Project: airgram   File: CustomTabsSessionToken.java   View source code 4 votes vote down vote up
public static CustomTabsSessionToken getSessionTokenFromIntent(Intent intent) {
    Bundle b = intent.getExtras();
    IBinder binder = BundleCompat.getBinder(b, "android.support.customtabs.extra.SESSION");
    return binder == null ? null : new CustomTabsSessionToken(ICustomTabsCallback.Stub.asInterface(binder));
}
 
Example 14
Project: Lyra   File: IBinderCoderTest.java   View source code 4 votes vote down vote up
@Test
public void testSerializeIBinder() {
    IBinder expectedValue = new Binder();
    mCoder.serialize(bundle(), randomKey(), expectedValue);
    assertEquals(expectedValue, BundleCompat.getBinder(bundle(), randomKey()));
}
 
Example 15
Project: Lyra   File: IBinderCoderTest.java   View source code 4 votes vote down vote up
@Test
public void testDeserializeIBinder() {
    IBinder expectedValue = new Binder();
    BundleCompat.putBinder(bundle(), randomKey(), expectedValue);
    assertEquals(expectedValue, mCoder.deserialize(bundle(), randomKey()));
}
 
Example 16
Project: PlusGram   File: CustomTabsSessionToken.java   View source code 4 votes vote down vote up
public static CustomTabsSessionToken getSessionTokenFromIntent(Intent intent) {
    Bundle b = intent.getExtras();
    IBinder binder = BundleCompat.getBinder(b, "android.support.customtabs.extra.SESSION");
    return binder == null ? null : new CustomTabsSessionToken(ICustomTabsCallback.Stub.asInterface(binder));
}
 
Example 17
Project: chromium-for-android-56-debug-video   File: CustomTabsSessionToken.java   View source code 3 votes vote down vote up
/**
 * 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.
 */
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));
}
 
Example 18
Project: chromium-for-android-56-debug-video   File: CustomTabsIntent.java   View source code 3 votes vote down vote up
/**
 * Creates a {@link CustomTabsIntent.Builder} object associated with a given
 * {@link CustomTabsSession}.
 *
 * Guarantees that the {@link Intent} will be sent to the same component as the one the
 * session is associated with.
 *
 * @param session The session to associate this Builder with.
 */
public Builder(@Nullable CustomTabsSession session) {
    if (session != null) mIntent.setPackage(session.getComponentName().getPackageName());
    Bundle bundle = new Bundle();
    BundleCompat.putBinder(
            bundle, EXTRA_SESSION, session == null ? null : session.getBinder());
    mIntent.putExtras(bundle);
}
 
Example 19
Project: AndroidChromium   File: CustomTabsSessionToken.java   View source code 3 votes vote down vote up
/**
 * 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.
 */
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));
}
 
Example 20
Project: AndroidChromium   File: CustomTabsIntent.java   View source code 3 votes vote down vote up
/**
 * Creates a {@link CustomTabsIntent.Builder} object associated with a given
 * {@link CustomTabsSession}.
 *
 * Guarantees that the {@link Intent} will be sent to the same component as the one the
 * session is associated with.
 *
 * @param session The session to associate this Builder with.
 */
public Builder(@Nullable CustomTabsSession session) {
    if (session != null) mIntent.setPackage(session.getComponentName().getPackageName());
    Bundle bundle = new Bundle();
    BundleCompat.putBinder(
            bundle, EXTRA_SESSION, session == null ? null : session.getBinder());
    mIntent.putExtras(bundle);
}
 
Example 21
Project: custom-tabs-client   File: CustomTabsSessionToken.java   View source code 3 votes vote down vote up
/**
 * 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.
 */
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));
}
 
Example 22
Project: custom-tabs-client   File: TrustedWebUtils.java   View source code 3 votes vote down vote up
/**
 * 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.
 */
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);
}
 
Example 23
Project: custom-tabs-client   File: CustomTabsIntent.java   View source code 3 votes vote down vote up
/**
 * Creates a {@link CustomTabsIntent.Builder} object associated with a given
 * {@link CustomTabsSession}.
 *
 * Guarantees that the {@link Intent} will be sent to the same component as the one the
 * session is associated with.
 *
 * @param session The session to associate this Builder with.
 */
public Builder(@Nullable CustomTabsSession session) {
    if (session != null) mIntent.setPackage(session.getComponentName().getPackageName());
    Bundle bundle = new Bundle();
    BundleCompat.putBinder(
            bundle, EXTRA_SESSION, session == null ? null : session.getBinder());
    mIntent.putExtras(bundle);
}
 
Example 24
Project: 365browser   File: CustomTabsSessionToken.java   View source code 3 votes vote down vote up
/**
 * 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.
 */
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));
}
 
Example 25
Project: 365browser   File: CustomTabsIntent.java   View source code 3 votes vote down vote up
/**
 * Creates a {@link CustomTabsIntent.Builder} object associated with a given
 * {@link CustomTabsSession}.
 *
 * Guarantees that the {@link Intent} will be sent to the same component as the one the
 * session is associated with.
 *
 * @param session The session to associate this Builder with.
 */
public Builder(@Nullable CustomTabsSession session) {
    if (session != null) mIntent.setPackage(session.getComponentName().getPackageName());
    Bundle bundle = new Bundle();
    BundleCompat.putBinder(
            bundle, EXTRA_SESSION, session == null ? null : session.getBinder());
    mIntent.putExtras(bundle);
}
 
Example 26
Project: anticipate   File: CustomTabsSessionToken.java   View source code 3 votes vote down vote up
/**
 * 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.
 */
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));
}
 
Example 27
Project: anticipate   File: CustomTabsIntent.java   View source code 3 votes vote down vote up
/**
 * Creates a {@link CustomTabsIntent.Builder} object associated with a given
 * {@link CustomTabsSession}.
 *
 * Guarantees that the {@link Intent} will be sent to the same component as the one the
 * session is associated with.
 *
 * @param session The session to associate this Builder with.
 */
public Builder(@Nullable CustomTabsSession session) {
    if (session != null) mIntent.setPackage(session.getComponentName().getPackageName());
    Bundle bundle = new Bundle();
    BundleCompat.putBinder(
            bundle, EXTRA_SESSION, session == null ? null : session.getBinder());
    mIntent.putExtras(bundle);
}
 
Example 28
Project: Telegram   File: CustomTabsSessionToken.java   View source code 3 votes vote down vote up
/**
 * 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.
 */
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));
}
 
Example 29
Project: Telegram   File: CustomTabsIntent.java   View source code 3 votes vote down vote up
/**
 * Creates a {@link CustomTabsIntent.Builder} object associated with a given
 * {@link CustomTabsSession}.
 *
 * Guarantees that the {@link Intent} will be sent to the same component as the one the
 * session is associated with.
 *
 * @param session The session to associate this Builder with.
 */
public Builder(@Nullable CustomTabsSession session) {
    if (session != null) mIntent.setPackage(session.getComponentName().getPackageName());
    Bundle bundle = new Bundle();
    BundleCompat.putBinder(
            bundle, EXTRA_SESSION, session == null ? null : session.getBinder());
    mIntent.putExtras(bundle);
}
 
Example 30
Project: Lyra   File: IBinderCoder.java   View source code 2 votes vote down vote up
/**
 * 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
 */
@Override
public void serialize(@NonNull Bundle state, @NonNull String key, @NonNull IBinder fieldValue) {
    BundleCompat.putBinder(state, key, fieldValue);
}