title: Show Google Search Results in Search Bar WebView
body: <p>I have an Edit Text Field in my layout, but the problem is, it's not working because i have to type the full url in the field to open a website like "<a href="http://www.google.co.in" rel="nofollow noreferrer">http://www.google.co.in</a>" but i want it to be able to search also like "google" or "android" but i have no idea how to do it. below is my code (there is no edit text in the code). i found an answer here but i don't know how to do it </p>
  
  <p><a href="https://stackoverflow.com/questions/16955560/how-to-show-android-google-default-search-results-in-webview">How to show Android Google default search results in webview?</a></p>
  
  <pre><code>import android.app.Activity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.webkit.WebChromeClient;
  import android.webkit.WebView;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.ProgressBar;
  
  public class MainActivity extends Activity {
  private WebView mWebView;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  
  CookieManager.getInstance().setAcceptCookie(true);//Enable Cookies
  mWebView = (WebView) findViewById(R.id.webView1);
  mWebView.getSettings().setJavaScriptEnabled(true);//Enable Java Script
  mWebView.setWebViewClient(new HelloWebViewClient());
  mWebView.loadUrl("http://www.google.com/"); //Set Home page
  mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);//Remove ScrollBars
  mWebView.getSettings().setDefaultFontSize(12);//Set Font Size
  mWebView.getSettings().setLoadsImagesAutomatically(true);//Enable Image Loading
  mWebView.getSettings().setPluginState(PluginState.ON);//Enable Flash
  mWebView.getSettings().setRenderPriority(RenderPriority.HIGH); //improves Feedback         on touch
  mWebView.setBackgroundColor(0x00000000);//Transparent Screen When Loading
  //mWebView.getSettings().setBuiltInZoomControls(true);//Set Zoom Controls 
  //mWebView.getSettings().setDisplayZoomControls(false);//Requires Api 11
  mWebView.getSettings().setAppCacheMaxSize(1024*1024*8);//Set Cache (8mb)
  String appCachePath =         getApplicationContext().getCacheDir().getAbsolutePath();//Set Cache (8mb)
  mWebView.getSettings().setAppCachePath(appCachePath);//Set Cache (8mb)
  mWebView.getSettings().setAllowFileAccess(true);//Set Cache (8mb)
  mWebView.getSettings().setAppCacheEnabled(true);//Set Cache (8mb)
  mWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);//Set Cache (8mb)
  
  
  }
  private class HelloWebViewClient extends WebViewClient {
  @Override
  public boolean shouldOverrideUrlLoading(WebView webview, String url)
  {
  
  
  webview.loadUrl(url);
  return true;
  }
  }
  
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event)
  {
  
  if ((keyCode == KeyEvent.KEYCODE_BACK) &amp;&amp; mWebView.canGoBack())
  
  {
  mWebView.goBack();
  return true;
  }
  return super.onKeyDown(keyCode, event);
  }
  }
  </code></pre>
  
  <p>Xml</p>
  
  <pre><code>&lt;RelativeLayout 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"
  tools:context=".WebViewActivity" &gt;
  
    &lt;LinearLayout
      android:id="@+id/urlContainer"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal" &gt;
  
      &lt;EditText
          android:id="@+id/urlField"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_weight="3"
          android:hint="Enter URL to open" /&gt;
  
      &lt;Button
          android:id="@+id/goButton"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:text="Open" /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;WebView
      android:id="@+id/webView1"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_below="@id/urlContainer" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>