HTML Viewer Example

This example shows how you can show HTML files into your application.
1.) Create a new project by File-> New -> Android Project name it HTMLViewerExample.

2.) Put a .htm file into your assets folder, name it “example.htm” and write following code into it:

 

 

 

3.) Run for output.

Steps:

1.) Create a project named HTMLViewerExample and set the information as stated in the image.

Build Target: Android 2.2
Application Name: HTMLViewerExample
Package Name: com.org.HTMLViewerExample
Activity Name: HTMLViewerExampleActivity
Min SDK Version: 8

2.) Open HTMLViewerExampleActivity.java file and write following code there:

 

 

 

4.) Compile and build the project.

Output

Leave a Comment:

10 comments
Iomar says January 6, 2012

I could not reproduce this example. It could put the entire project.

Thanks

Reply
Ravi says January 7, 2012

What is the difference between these two

wb.loadUrl(“file:///android_asset/example.htm”);

wb.loadUrl(“www.google.com”);

Reply
Brent says February 6, 2012

Nice article, great for beginners. However I have a question, is there anyway to get rid of the application title above the webview when ran? and is there any way to remove the white bar along the right side of the app?

Reply
Brent says February 6, 2012

Nice article, great for beginners. However I have a question, is there anyway to get rid of the application title above the webview when ran? and is there any way to remove the white bar along the right side of the app??

Reply
sam says May 3, 2012

I got this error when I tried to build it:

[2012-05-03 16:11:43 – HtmlViewerExample] Uploading HtmlViewerExample.apk onto device ’emulator-5554′
[2012-05-03 16:11:44 – HtmlViewerExample] Installing HtmlViewerExample.apk…
[2012-05-03 16:13:45 – HtmlViewerExample] Failed to install HtmlViewerExample.apk on device ’emulator-5554!
[2012-05-03 16:13:45 – HtmlViewerExample] (null)
[2012-05-03 16:13:45 – HtmlViewerExample] Launch canceled!

Reply
sam says May 3, 2012

I got this error when I tried to build it:

[2012-05-03 16:11:43 – HtmlViewerExample] Uploading HtmlViewerExample.apk onto device ’emulator-5554′
[2012-05-03 16:11:44 – HtmlViewerExample] Installing HtmlViewerExample.apk…
[2012-05-03 16:13:45 – HtmlViewerExample] Failed to install HtmlViewerExample.apk on device ’emulator-5554!
[2012-05-03 16:13:45 – HtmlViewerExample] (null)
[2012-05-03 16:13:45 – HtmlViewerExample] Launch canceled!

Reply
sam says May 3, 2012

I got this error when I tried to build it:

[2012-05-03 16:11:43 – HtmlViewerExample] Uploading HtmlViewerExample.apk onto device \’emulator-5554\’
[2012-05-03 16:11:44 – HtmlViewerExample] Installing HtmlViewerExample.apk…
[2012-05-03 16:13:45 – HtmlViewerExample] Failed to install HtmlViewerExample.apk on device \’emulator-5554!
[2012-05-03 16:13:45 – HtmlViewerExample] (null)
[2012-05-03 16:13:45 – HtmlViewerExample] Launch canceled!

Reply
Anilkamal says September 4, 2012

Thats great tutorial

Reply
flac download says November 16, 2012

Appear of your website is changed, do you are doing it all
by yourself?

Reply
derek says December 11, 2012

Hi,
Great tutorial.
I try to use your tutorial to create a project – Similar, but my html page
is a html5 website which contain sub-folders but I can not make it work.

If possible, Can you guys create a sample project on how to run a html5 & Flash website in webview (saved in the assets folder).

I have been stuck on my project for 4 days, I have done quite a lot of looking around and no data available, well nothing that can find. I read some forum that say, it can not be done and other give a page of code just to enable html5 in webview but I can not see all the code making it more confusing.

Reply
Add Your Reply