Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jtmuller5/09fcdf86b413c9a3a2304a120c148022 to your computer and use it in GitHub Desktop.
Save jtmuller5/09fcdf86b413c9a3a2304a120c148022 to your computer and use it in GitHub Desktop.
StartActivity Intent for Custom Tabs URL
val sendLinkIntent = Intent(main,MainActivity::class.java)
sendLinkIntent.putExtra(Intent.EXTRA_SUBJECT,"This is the link you were exploring")
val pendingIntent = PendingIntent.getActivity(main,0,sendLinkIntent,PendingIntent.FLAG_UPDATE_CURRENT)
// Set the action button
AppCompatResources.getDrawable(main, R.drawable.close_icon)?.let {
DrawableCompat.setTint(it, Color.WHITE)
builder.setActionButton(it.toBitmap(),"This is your link",pendingIntent,false)
}
// Create the Custom Tabs Intent and launch the URL
val customTabsIntent: CustomTabsIntent = builder.build()
customTabsIntent.launchUrl(main, Uri.parse(url))
@Prasildas
Copy link

With out an icon click or action can we get the url?
Lets assume that I have a url, which internally redirects I have to capture or intercept one url and then post data to another url. I have done the same in webview. I could not find the same to do in custom tab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment