The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.
HTML has come a long way from Sir Tim Berners-Lee’s original vision of using it to publish physics papers.
There are a couple of ways to display HTML in Android, with the most powerful
WebView widget, the focus of this chapter.
If your HTML is fairly limited in scope, such as what you might find in the
body of a status update on Twitter, you can use the static
Html utility class to parse an HTML-formatted string into something
that you can put into a
TextView can render simple formatting
like styles (bold, italic, etc.), font faces (serif, sans serif, etc.), colors,
links, and so forth.
However, sometimes your needs for HTML transcend what
TextView can handle.
You will not be browsing Facebook using
TextView, for example.
In those cases,
WebView will be the more appropriate widget, as it can
handle a much wider range of HTML tags.
WebView can also handle CSS and
Html.fromHtml() would simply ignore.
WebView can also
assist you with common “browsing” metaphors, such as history list of visited
URLs to support backwards and forwards navigation.
On the other hand,
WebView is a much more expensive widget to use, in terms
of memory consumption, than is
Originally, the story was simple:
WebView was powered by a fairly
complete copy of WebKit, the Web rendering
engine behind Safari and, originally, Chrome.
In Android 4.4, Google switched rendering engines. Depending on who
WebView was powered by Chromium
or Blink. Chromium is an open source
browser that forms the foundation for Google’s Chrome, and Blink is
a fork of WebKit created by Opera and Google that, in turn, powers
Starting in Android 5.0, the implementation of
WebView was no
longer a part of Android. Rather, it became a separate “System WebView”
app, distributed through the Play Store. The idea was that
this app could be updated independently of the device firmware, so that
WebView bugs could be fixed more rapidly and distributed to more
devices. This also means that Google can distribute new and exciting
bugs more quickly (and independently of Android OS version),
as will be discussed later in the chapter.
In Android 7.0, the implementation of
WebView will be from one of two
The documented dependency of
WebView on apps distributed through the Play Store
makes things very murky for non-Play ecosystem devices, such as most devices
in China. Most likely, individual manufacturers do their own thing
with respect to updating
As a result, from the standpoint of security and compatibility,
is a “hot mess”.
The preview of this section is off trying to sweet-talk the Khaleesi into providing us with a dragon.
The preview of this section is presently indisposed.
The preview of this section was traded for a bag of magic beans.
The preview of this section was stepped on by Godzilla.
The preview of this section took that left turn at Albuquerque.
The preview of this section was lost in the sofa cushions.
The preview of this section was eaten by a grue.
The preview of this section may contain nuts.