Android – Apps can easily embed the web

Android – Apps can easily embed the web


>>MIKE: Hi. My name is Mike and I’m an engineer
on the Android team. I’m going to show you how you can easily embed web content into
your application. This includes HTML, CSS, and JavaScript. In addition to displaying
this content, you can also control it from your application. This is done with an embedded
WebView. Now, the Gmail application that’s included with Android actually uses an embedded
WebView in order to display the contents of a conversation. We have all the HTML fragments
for each message in the conversation stored in a database and then we put those together
and display them in a WebView. The WebView actually looks like it’s part of the Gmail
application because it is part of the Gmail application. For example, if I bring up the
menu, the menu contains all the menu items you’d expect to see in Gmail and not the kind
of menu items you expect to see in the browser. There’s also two-way communication between
the content that’s displayed in the WebView and the Java application, that’s the Gmail
application itself. So, for example, if I touch on the first item in the list, you can
see that it expands, and the content for that comes from the JavaScript that’s running inside
the WebView, calling out into my Java code to get the next fragment for HTML and putting
it back into the DOM. You can also have communication going the other way. So if I star a message,
then my Java code is going to push a change into the DOM by executing some JavaScript.
And you can see that here. Now, if you want to use these techniques yourself, we have
some sample code available on the Apps for Android site that shows how to embed a WebView
and how to have communication in and out of that WebView from your activity. Using a WebView
is a really good option if you all ready have a lot of content in HTML and JavaScript, and
it provides a really nice seamless experience for the user.

5 thoughts on “Android – Apps can easily embed the web

  1. Hi Mike

    How can we play html5 video in Android webview?

    Is there any video type that is supported in webview?

    Thanks
    Josh

Leave a Reply

Your email address will not be published. Required fields are marked *