On iOS, there are 3 ways to display web content (as I was told by a iOS dev):
UIWebView
displayed inside a UIControllerView
if I am correctSFSafariViewController
as a UIControllerView
Safari
, the app itself on Android, as far as I am concerned, there are only two ways:
WebView
(inside a Fragment
or Activity
layout)Action.View
Intent
). Anyway, the advantage of the SFSafariViewController
is that you have a full-fledged web browser in your app without leaving your app with a constant UX across the entire OS.
Recently, I came across apps such as Reddit or the French railway app (OuiSNCF) where web content are displayed in a manner that looks definitely like the SFSafariViewController
on iOS:
Activity
But looking on the internet and here on SO, I can only find ways to launch Chrome itself via Intents. Looking for ChromeView
I stumbled on some projects, nothing official.
So here I am asking this question: is this official in any way? Is there really a sort of ChromeWebView
similar to that of the SFSafariViewController
on iOS? If yes, how can it be implemented?
Thanks for the answers !
It seems there is indeed an official way: Chrome Custom Tabs
as detailed here: https://developer.chrome.com/multidevice/android/customtabs .
Yes You can achieve this by using CustomTabs
Add this to your app/build.gradle
file
dependencies {
implementation "androidx.browser:browser:1.3.0"
}
For Java
String url = "https://paypeg.me/";
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse(url));
For Kotlin
val url = "https://paypeg.me/"
CustomTabsIntent.Builder()
.build()
.launchUrl(context, Uri.parse(url))
More customisation here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.