Modern WebView best practices (Android Dev Summit '18)

Android Developers · 31K views · 2018 · 14:42

Open on YouTube

Software (other)Web developmenttalkdated

Why Stack Overflow recommends it

Stack Overflow users link it as an official source on WebView practices, such as the Chromium team's Base64 recommendation for loadData, and as an overview of WebViewCompat.

Recommended by 1 people across 1 different months, 2019 to 2019.

What it is

A 14-minute Android Dev Summit 2018 session in which the WebView team (Nate Fischer, Richard Coles and Toby Sargeant) cover best and worst practices for embedding WebView in Android apps. It also introduces the WebViewCompat support library for applying those practices across Android versions.

What people said

Recommends Pascal · 2019-02 · Stack Overflow · on “Android. WebView and loadData”

The safest way to load htmlContent in a Web view is to: use base64 encoding (official recommendation) specify UFT-8 for html content type, i.e., "text/html; charset=utf-8" instead of "text/html" (personal advice) "Base64 encoding" is an official recommendation that has been written again (already present in Javadoc) in the latest 01/2019 bug in Chrominium (present in WebView M72 (72.0.3626.76)): [LINK] OFFICIAL statement from CHROMIUM TEAM: "Recommended fix: Our team recommends you encode data with Base64. We've provided examples for how to do so: API docs: [LINK] Video talk: [this video] (jump to 9:58) This fix is backwards compatible (it works on earlier WebView versions), and should also be fu

Cites Christian D · 2019-01 · Stack Overflow · on “Sample usage of WebViewCompat”

Found a video from the 2018 Android Dev Summit explaining the new WebViewCompat inside Android X: [this video] But it does not contain useful code examples: :(

Cites Brian Reinhold · 2019-05 · Stack Overflow · on “Rendering a local HTML file with a local image in WebView”

I am trying to render a local html file with a local image in a WebView where the WebView is in a Dialog Box and not an Activity. The image is not being rendered, but the remainder of the info is displayed just fine. There are countless solutions to this problem suggested in Stack Overflow, many with green check marks. None that I have tried have worked. What I am doing is placing the html file and the image in res/raw The html file has a line referencing the image; I have tried different options all which have been stated somewhere in stack overflow as working, for example: <img src="file:///android_res/raw/main_screen_crop.png" alt="Main Screen" width="525" height="290"> and <img src="main