Here are the examples of the java api class android.support.customtabs.CustomTabsIntent taken from open source projects.
1. ExternalLinkUtil#openLinkInBrowser()
Project: muzei
File: ExternalLinkUtil.java
File: ExternalLinkUtil.java
public static void openLinkInBrowser(Context context, Uri uri) { CustomTabsIntent cti = new CustomTabsIntent.Builder().setShowTitle(true).setToolbarColor(ContextCompat.getColor(context, R.color.theme_primary)).build(); Intent intent = cti.intent; intent.setData(uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { context.startActivity(intent); } catch (ActivityNotFoundException ignored) { } }
2. CompatV16#openUrl()
Project: Anki-Android
File: CompatV16.java
File: CompatV16.java
@Override public void openUrl(AnkiActivity activity, Uri uri) { CustomTabActivityHelper helper = activity.getCustomTabActivityHelper(); CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(helper.getSession()); builder.setToolbarColor(ContextCompat.getColor(activity, R.color.material_light_blue_500)).setShowTitle(true); builder.setStartAnimations(activity, R.anim.slide_right_in, R.anim.slide_left_out); builder.setExitAnimations(activity, R.anim.slide_left_in, R.anim.slide_right_out); builder.setCloseButtonIcon(BitmapFactory.decodeResource(activity.getResources(), R.drawable.ic_arrow_back_white_24dp)); CustomTabsIntent customTabsIntent = builder.build(); CustomTabsHelper.addKeepAliveExtra(activity, customTabsIntent.intent); CustomTabActivityHelper.openCustomTab(activity, customTabsIntent, uri, new CustomTabsFallback()); }
3. MainActivity#openGitHubPage()
Project: hashtag-view
File: MainActivity.java
File: MainActivity.java
public void openGitHubPage() { CustomTabsIntent intent = new CustomTabsIntent.Builder().setToolbarColor(ContextCompat.getColor(this, R.color.primary)).setShowTitle(true).setStartAnimations(this, R.anim.enter_from_right, R.anim.exit_to_left).setExitAnimations(this, R.anim.enter_from_left, R.anim.exit_to_right).build(); intent.launchUrl(this, Uri.parse(getString(R.string.github))); }
4. AppUtil#showWebPage()
Project: droidkaigi2016
File: AppUtil.java
File: AppUtil.java
public static void showWebPage(Activity activity, @NonNull String url) { CustomTabsIntent intent = new CustomTabsIntent.Builder().setShowTitle(true).setToolbarColor(ContextCompat.getColor(activity, R.color.theme500)).build(); intent.launchUrl(activity, Uri.parse(url)); }
5. AndroidUtils#openLinkInBrowser()
Project: Clover
File: AndroidUtils.java
File: AndroidUtils.java
public static void openLinkInBrowser(Activity activity, String link) { CustomTabsIntent intent = new CustomTabsIntent.Builder().setToolbarColor(theme().primaryColor.color).build(); intent.launchUrl(activity, Uri.parse(link)); }
6. Utils#createExternalIntent()
Project: frisbee
File: Utils.java
File: Utils.java
@SuppressWarnings("deprecation") public static Intent createExternalIntent(Context context, Uri uri) { CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().setToolbarColor(context.getResources().getColor(R.color.theme_primary)).setShowTitle(true).build(); Intent intent = customTabsIntent.intent; intent.setData(uri); return intent; }