Essential Android Intent edit forum

CustomTabsIntent for Chrome Custom Tabs

Using a CustomTabsIntent, it is now possible to configure Chrome custom tabs in order to customize key UI components in the browser that is opened from your app.

This is a good alternative to using a WebView for some cases. It allows loading of a web page with an Intent, with the added ability to inject some degree of the look and feel of your app into the browser.

Here is an example of how to open a url using CustomTabsIntent

String url = "https://www.google.pl/";
CustomTabsIntent intent = new CustomTabsIntent.Builder()
                    .setStartAnimations(getContext(), R.anim.slide_in_right, R.anim.slide_out_left)
                    .setExitAnimations(getContext(), android.R.anim.slide_in_left, android.R.anim.slide_out_right)
                    .setCloseButtonIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_arrow_back_white_24dp))
                    .setToolbarColor(Color.parseColor("#43A047"))
                    .enableUrlBarHiding()
                    .build();
            intent.launchUrl(getActivity(), Uri.parse(url));

Note:

To use custom tabs, you need to add this dependency to your build.gradle

compile 'com.android.support:customtabs:24.1.1'

Table Of Contents
6 Intent
39 ACRA
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close