android-browser-helper, a new library to build Trusted Web Activities.

Published on Updated on

We have released version 1.0.0 of, android-browser-helper, a new Android Library for Trusted Web Activity which, besides being built on top of the modern Android JetPack libraries, makes it easier for developers to use Trusted Web Activity to build their Android applications.

android-browser-helper is now the recommended library to build applications that use Trusted Web Activity.

The library is hosted on the official Google Maven repository, which works out of the box in Android Projects, and is also compatible with AndroidX, which was a common issue with the previous library.

More features and development experience improvements will be added this library. This is a short list of what has already been added:

  • Handles opening the content in a browser that supports Trusted Web Activities and, if one is not installed, implements a fallback strategy.
  • Makes the fallback strategy customizable, so developers can customize how their application behaves when a browser the supports Trusted Web Activities is not installed. The twa-webview-fallback demo shows how to use a fallback strategy that uses the Android WebView, for example.
  • Makes configuring Trusted Web Actitivities that work with multiple origins easier, as illustrated on the twa-multi-domain]4 demo.

The library can be added to Android application by using the following dependency to the appllication build.gradle:

dependencies {
//...
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.2.0'
}

Migrating from the custom-tabs-client #

Developers who were using the previous custom-tabs-client will have to implement a few changes in their application, when migrating to android-browser-helper.

Fortunately, besides replacing using the old library with the new library, those changes mainly involve changing searching and replacing a few strings throughout AndroidManifest.xml.

Here's a summary of the names changed:

Name on custom-tabs-client (Old Library)Name on android-browser-helper (New Library)
android.support.customtabs.trusted.LauncherActivitycom.google.androidbrowserhelper.trusted.LauncherActivity
android.support.v4.content.FileProviderandroidx.core.content.FileProvider
android.support.customtabs.trusted.TrustedWebActivityServicecom.google.androidbrowserhelper.trusted.DelegationService

The svgomg-twa demo has been updated to use android-browser-helper. this diff shows all the changes required when migrating an existing project using custom-tabs-client to android-browser-helper.

Are we missing anything? #

android-browser-helper has the goal of simplifying the development of applications using Trusted Web Activities. The library will continue to evolve as Trusted Web Activity get more features.

If you are missing a feature in Trusted Web Activities, think of ways that android-browser-helper could make make the development work simpler, or have a question on how to use the library, make sure to pop by the GitHub repository and file an issue.

Feedback #

Last updated: Improve article

We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.