Let's sum up the answers:
-First, your application MUST have permission to access internet. You can do it by using this code block in your projects "AndroidManifest.xml" file:
<uses-permission android:name="android.permission.INTERNET" />
Put this code block in manifest tag, not in application tag. Like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.yourproject
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="20" />
<!-- Permission here -->
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="....
-Second, you must design a UI in xml which contains a WebView widget. Codes in other answers show you how to do it properly:
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
This is xml code of a webview inside your layout file. After you implement a webView to your layout.
-Last, follow code TeRRo gave, you can use it to show whatever page you want to load by changing web adress he wrote as example. Reposting it here:
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.google.com");
}