title: Access to Browser history on Android Application
body: <p>I have created a simple browser application with a edittext , go button and history button.
  Please suggest what coding do i need to implement for history button such that when i press it my browsing history gets displayed on the hi.xml layout. Please suggest what coding changes do i need to make in my xml file as well as java file .</p>
  
  <p>MainActivity.java:</p>
  
  <pre><code>package com.example.history;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.view.Menu;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.inputmethod.InputMethodManager;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  import android.widget.Button;
  import android.widget.EditText;
  
  
  public class MainActivity extends Activity implements OnClickListener{
  
  EditText t;
  Button g,h;
  WebView w;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      g=(Button) findViewById(R.id.button1);
      h=(Button) findViewById(R.id.button2);
      t=(EditText) findViewById(R.id.editText1);
      w=(WebView) findViewById(R.id.webView1);
      h.setOnClickListener(this);
      g.setOnClickListener(this);
      w.getSettings().setJavaScriptEnabled(true);
      w.getSettings().setLoadWithOverviewMode(true);
      w.getSettings().setUseWideViewPort(true);
      w.setWebViewClient(new Callback());
  
  
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  
  @Override
  public void onClick(View arg0) {
      // TODO Auto-generated method stub
      switch(arg0.getId())
      {
      case R.id.button1:
          String c;
          c=t.getText().toString();
          String theWebsite=("http://").concat(c);
          t.setText(theWebsite);
          w.loadUrl(theWebsite);
          InputMethodManager imm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
          imm.hideSoftInputFromWindow(w.getWindowToken(),0);
  
  
          break;
      case R.id.button2:
          Intent a=new Intent(MainActivity.this,h.class);
          startActivity(a);
  
          break;
  
  
  
      }
  
  
  }
  
  }
  class Callback extends WebViewClient{   
  
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
      return (false);
  }
  
  }
  </code></pre>
  
  <p>activity_main.xml:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context=".MainActivity" &gt;
  
  &lt;TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/hello_world" /&gt;
  
  &lt;EditText
      android:id="@+id/editText1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/textView1"
      android:layout_below="@+id/textView1"
      android:layout_marginLeft="15dp"
      android:layout_marginTop="16dp"
      android:ems="10" /&gt;
  
  &lt;Button
      android:id="@+id/button1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/editText1"
      android:layout_marginTop="34dp"
      android:layout_toRightOf="@+id/textView1"
      android:text="Go" /&gt;
  
  &lt;Button
      android:id="@+id/button2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/button1"
      android:layout_centerVertical="true"
      android:text="History" /&gt;
  
  &lt;WebView
      android:id="@+id/webView1"
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>h.java:</p>
  
  <pre><code>package com.example.history;
  
  import android.app.Activity;
  import android.os.Bundle;
  
  public class h extends Activity{
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.hi);
  }
  
  }
  </code></pre>
  
  <p>hi.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" &gt;
  
  &lt;ListView
      android:id="@+id/listView1"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" &gt;
  &lt;/ListView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>