@Test(expected = ActivityNotFoundException.class) public void testTrustedWebIntentContainsRequiredExtra() { CustomTabsSession mockSession = CustomTabsSession.createMockSessionForTesting( mActivityTestRule.getActivity().getComponentName()); CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder(mockSession).build(); TrustedWebUtils.launchAsTrustedWebActivity( mActivityTestRule.getActivity(), customTabsIntent, Uri.EMPTY); assertNotNull(BundleCompat.getBinder( customTabsIntent.intent.getExtras(), CustomTabsIntent.EXTRA_SESSION)); assertEquals(customTabsIntent.intent.getAction(), Intent.ACTION_VIEW); assertTrue(customTabsIntent.intent.hasExtra( TrustedWebUtils.EXTRA_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); }
TrustedWebUtils { 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); } }
TrustedWebUtils { 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); } private  TrustedWebUtils(); }
TrustedWebUtils { 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); } private  TrustedWebUtils(); static void launchAsTrustedWebActivity(@NonNull Context context,
            @NonNull CustomTabsIntent customTabsIntent, @NonNull Uri uri); }
TrustedWebUtils { 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); } private  TrustedWebUtils(); static void launchAsTrustedWebActivity(@NonNull Context context,
            @NonNull CustomTabsIntent customTabsIntent, @NonNull Uri uri); static final String EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY; }