Android Tutorial

(avery) #1
Android Tutorial 385

classes available, as you are likely to need them to enhance the
WebView user experience.


These are not classes and interfaces to the Browser app (although
you can interact with the Browser data using contact providers).
Instead, these are the classes and interfaces that you must use to
control the browsing abilities of WebView controls you implement in
your applications.


Browsing the WebKit APIs


Some of the most helpful classes of the android.webkit package are


 The CacheManager class gives you some control over cache items of a
WebView.
 The ConsoleMessage class can be used to retrieve JavaScript console
output from a WebView.
 The CookieManager class is used to set and retrieve user cookies for a
WebView.
 The URLUtil class is handy for validating web addresses of different types.
 The WebBackForwardList and WebHistoryItem classes can be used to
inspect the web history of the WebView.

Now let’s take a quick look at how you might use some of these
classes to enhance a WebView.


Extending Web Application Functionality to Android


Let’s take some of the WebKit features we have discussed so far in
this chapter and work through an example. It is fairly common for
mobile developers to design their applications as web applications
in order to reach users across a variety of platforms. This
minimizes the amount of platform-specific code to develop and

Free download pdf