Helpers of the Chrome Custom tabs re-written in Kotlin and with Architecture Components to offer a simpler API
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app Add an extension function Aug 18, 2018
customtabs update version Aug 18, 2018
gradle/wrapper push project Aug 18, 2018
.gitignore update gitignore Aug 18, 2018
LICENSE Initial commit Aug 18, 2018
README.md Update README.md Aug 18, 2018
build.gradle convert files to Kotlin Aug 18, 2018
gradle.properties push project Aug 18, 2018
gradlew push project Aug 18, 2018
gradlew.bat push project Aug 18, 2018
settings.gradle add custom tabs library module Aug 18, 2018

README.md

Chrome Custom Tabs - Kotlin and Lifecycle Aware

This is a rewrite of the helpers offered by Google.

The ones offered by Google are written in JAVA and require integration with the Activity lifecycle if the user needs to support warmup of the browser for performance gains.

  • This new implementaion uses Lifecycle to hide away the service binding logic.
  • Rewritting in Kotlin makes the code consixe and offers a cleaner and easier to work with API, espcially with the support of optional paramters.

Usage

Add a dependency to your build.gradle:

dependencies {
    implementation 'com.saurabharora.customtabs:customtabs:1.0.0'
}

Now in your Activity/Fragment from where you want to launch the Chrome Custom Tabs:

private val  customTabActivityHelper: CustomTabActivityHelper =
    CustomTabActivityHelper(context = this, lifecycle = lifecycle, connectionCallback = this)
    
//If you know the potential URL that will be loaded:
customTabActivityHelper.mayLaunchUrl(uri)
    
val customTabsIntent = CustomTabsIntent.Builder(customTabActivityHelper.session)
                       .build()
                       
customTabsIntent.launchWithFallback(activity = this, uri = uri)

See the demo app for more details.