user1158831
user1158831

Reputation: 533

Android WebView not loading url on emulator running on a machine connected to internet through Proxy

I am using the below sample code I got from internet. I have set internet permission in the manifest file. Still I always get a white screen, after sometime it gives message "Webpage not available". Its running on Android 4, avd on a corporate machine.My Internet connection is working fine, on the default browser, through the proxy settings I added for AVDs APN settings.

public class MyBrowser extends Activity{

WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    
    setContentView(R.layout.mybrowser);
    
    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    
    mWebView.setWebViewClient(new MyBrowserClient());

    mWebView.loadUrl("www.google.com" );
}


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

}

Below is what I have in my Android Manifest, just above the application tag.

    <uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

I could see that sometimes the logCat throws the below error.

05-31 18:50:17.415: W/webcore(1437): java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up.

Upvotes: 0

Views: 3886

Answers (1)

Vipul
Vipul

Reputation: 28093

You have problem in following line

mWebView.loadUrl("www.google.com" );

Replace it with

mWebView.loadUrl("https://www.google.com" );

It Should work.

In short you must have http or https prefix.

Upvotes: 0

Related Questions