androidx.core.app.BundleCompat Java Examples

The following examples show how to use androidx.core.app.BundleCompat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShellButlerServiceBinder.java    From test-butler with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    Log.d(TAG, "ButlerApiBroadcastReceiver#onReceive was called");
    Bundle bundle = intent.getBundleExtra(ShellButlerService.BUTLER_API_BUNDLE_KEY);
    if (bundle != null) {
        IBinder binder = BundleCompat.getBinder(bundle, ShellButlerService.BUTLER_API_BUNDLE_KEY);
        butlerApi = ButlerApi.Stub.asInterface(binder);
        received.countDown();
    }
}
 
Example #2
Source File: ShellButlerService.java    From test-butler with Apache License 2.0 5 votes vote down vote up
private void broadcastButlerApi() throws Exception {
    Intent intent = new Intent(BROADCAST_BUTLER_API_ACTION);

    Bundle bundle = new Bundle();
    BundleCompat.putBinder(bundle, BUTLER_API_BUNDLE_KEY, butlerApi);
    intent.putExtra(BUTLER_API_BUNDLE_KEY, bundle);

    ActivityManagerWrapper.newInstance().broadcastIntent(intent);
}
 
Example #3
Source File: CustomTabsSessionToken.java    From Telegram-FOSS with GNU General Public License v2.0 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 #4
Source File: CustomTabsIntent.java    From Telegram-FOSS with GNU General Public License v2.0 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 #5
Source File: CustomTabsSessionToken.java    From Telegram with GNU General Public License v2.0 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 #6
Source File: CustomTabsIntent.java    From Telegram with GNU General Public License v2.0 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);
}