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" />
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With