Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android WebView Wrapper (In-App Browser) behavior

On recent versions of Android, opening a link from Google Search it opens on a wrapped version of the Chrome within Google Search app and it offers a option on the menu to 'open with Chrome'. This common pattern is also seen on other apps like Facebook, Twitter, etc. So basically it opens the link on a 'WebView wrapper' within the app instead of opening the Browser app.

An interesting thing is found on the one from Google Search, that when you click on the 'open with Chrome' it plays a very smooth transition to Chrome, like if it would get transformed into Chrome.

Is there any sample or library that kinda helps or wraps this behavior? Or an 'in-app browser' that wraps this activity behavior.

like image 307
iMobaio Avatar asked Sep 17 '17 19:09

iMobaio


People also ask

What is WebView wrapper?

The WebView class is an extension of Android's View class that allows you to display web pages as a part of your activity layout. It does not include any features of a fully developed web browser, such as navigation controls or an address bar. All that WebView does, by default, is show a web page.

Which browser is used in Android WebView?

Google combined WebView with Google Chrome for versions 7.0, 8.0 and 9.0. However, with Android 10.0, it went back to having it as a separate component. Users can update WebView in Android 10 through Google Play Store.

Is WebView an embedded browser?

Android System WebView is a system component that lets Android apps display web content inside them without opening a dedicated browser. In other words, Android System WebView is a web browser engine or an embedded web browser dedicated solely for apps to show web content.

Which method from the WebView class loads a web page?

The loadUrl() and loadData() methods of Android WebView class are used to load and display web page.


1 Answers

You're probably looking for Chrome Custom Tabs as Morrison Chang already mentioned.

Add implementation "androidx.browser:browser:1.3.0" to your build.gradle file.

You can open a new tab like this:

CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse("https://www.example.com"));

Further examples can be found in the Implementation guide.

like image 58
irgendwr Avatar answered Oct 21 '22 16:10

irgendwr