Skip to content

Instantly share code, notes, and snippets.

@jtmuller5
Created June 3, 2020 22:44
Show Gist options
  • Save jtmuller5/48bb1fba30fd3e4906bd09bb40f93cbb to your computer and use it in GitHub Desktop.
Save jtmuller5/48bb1fba30fd3e4906bd09bb40f93cbb to your computer and use it in GitHub Desktop.
Simple Custom Chrome Tabs Implementation
class SimpleTabsFragment : Fragment() {
private lateinit var dashboardViewModel: DashboardViewModel
var builder = CustomTabsIntent.Builder()
override fun onCreateView(inflater: LayoutInflater,container: ViewGroup?, savedInstanceState: Bundle?): View? {
dashboardViewModel = ViewModelProviders.of(this).get(DashboardViewModel::class.java)
val root = inflater.inflate(R.layout.fragment_simple_tabs, container, false)
return root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
simple_tabs_button.setOnClickListener {
var url = "www.google.com"
var customTabsIntent :CustomTabsIntent = builder.build();
customTabsIntent.launchUrl(requireContext(), Uri.parse(url))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment