Skip to content Skip to sidebar Skip to footer

How To Add EXTRA_REFERRER To CustomTabsIntent Builder In Chrome Custom Tab For Android

I am using newly launched Chrome Custom tabs for android instead of using webviews. This is the link to their documentation Here is the code that shows how to use it. String url =

Solution 1:

you can put the extra on the Intent that is inside the CustomTabsIntent created by the builder like the following:

String url = ¨https://paul.kinlan.me/¨;
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.putExtra(Intent.EXTRA_REFERRER,
        Uri.parse("android-app://" + context.getPackageName()));
customTabsIntent.launchUrl(this, Uri.parse(url));

Explanation: Under the hood, a Custom tab is opened by using regular a Intent with a set of Extras that configure the UI customization. It's possible to see more on how it works at the Low Level API section of the docs. When CustomTabsIntent.Builder#build() is called, it creates a CustomTabsIntent, with a properly configured Intent inside it. This intent is still exposed by the API and that's what we use to add the EXTRA_REFERRER.


Post a Comment for "How To Add EXTRA_REFERRER To CustomTabsIntent Builder In Chrome Custom Tab For Android"