Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebView not working in Android Emulator

Tags:

android

I have created one android project with simple web view.

I am trying to open google. But the emulator screen is saying Google not available.

I have added Internet permission in the manifest file. Even I am able to access google from Emulator browser. Only in the application, I am not able access. Nothing is printed in the log also.

Please help.

<?xml version="1.0" encoding="utf-8"?>
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
/>


public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.loadUrl("http://www.google.com");
    mWebView.setWebViewClient(new HelloWebViewClient());
}


private class HelloWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
    view.loadUrl(url);
    return true;
    }
}


  <uses-permission android:name="android.permission.INTERNET" />
like image 993
Bhabani Shankar Avatar asked Sep 08 '11 11:09

Bhabani Shankar


1 Answers

Your code above does not show the manifest file that gives rights to use internet. This process is detailed here: Building Web Apps in WebView

If you have further trouble you can test and download source code of this open source base application for Android: WebViewApp

like image 98
kingmaple Avatar answered Oct 13 '22 10:10

kingmaple