Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show web page in my app?

Tags:

android

webkit

I need to send from server side simple web pages (with images) some how (mht, or zipped web page folders) and show it on UI of my Android application without browser control, can someone advice my how to proceed with that on Android device?

like image 843
Fagoter Avatar asked May 25 '11 08:05

Fagoter


People also ask

What will you add to display a Web page in your app?

The WebView class is an extension of Android's View class that allows you to display web pages as a part of your activity layout.

How do I view web pages on Android?

String url = "http://www.example.com"; Intent i = new Intent(Intent. ACTION_VIEW); i. setData(Uri. parse(url)); startActivity(i);


1 Answers

To show a web page in your app, there are two ways to do it: use the default Browser of Android, or use a WebView. For the second one, you can do this:

WebView webView = (WebView)findViewById(R.id.webView);
//you can load an html code 
webView.loadData("yourCode Html to load on the webView " , "text/html" , "utf-8");
// you can load an URL 
webView.loadUrl("http://www.stackoverflow.com");

layout XML :

In your layout Xml, define an WebView like this:

<WebView android:id="@+id/webView"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent" />
like image 74
Houcine Avatar answered Oct 04 '22 12:10

Houcine