Atul Mittal Atul Mittal - 7 months ago 30
Android Question

Embedding a Web page in an Android App

I am trying to embed a webpage inside an android app.
Following is the code written in the main_activity java file of my app.

package com.example.webpage;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;

public class MainActivity extends ActionBarActivity {

protected void onCreate(Bundle savedInstanceState) {
WebView webview = new WebView(this);

public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(, menu);
return true;

public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == {
return true;
return super.onOptionsItemSelected(item);

The problem is whenever i launched my app in an emulator it shows me the "Page not Found" error.
Please help me out.
Output in the emulator


Try this:

  1. First, you take the webview in XML.

  2. Bind to them like:

    WebView webView = (WebView)findViewById(;
  3. Then do this:

    String url = "";
    WebView webView = (WebView)findViewById(;