WebView does not work in Android Emulator

I created one Android project with simple web browsing.

I am trying to open Google. But the emulator screen says that Google is unavailable.

I added permission to use the Internet to the manifest file. Even I can access Google from the Emulator browser. Only in the application I can not access. Nothing is printed in the journal either.

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" /> 
+4
source share
2 answers

delete or comment on this line

 mWebView.setWebViewClient(new HelloWebViewClient()); 

Since you redefined

 @Override public boolean shouldOverrideUrlLoading(WebView view, String url) 

and returned yes, it could mean that you have processed the URL loading. You basically don't need a subclass of webviewclient here

0
source

The above code does not have a manifest file that grants Internet usage rights. This process is described in detail here: Creating Web Applications in WebView

If you have additional problems, you can test and download the source code of this basic open source Android application: WebViewApp

0
source

All Articles