Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up

I have implemented WebView in Dialog Activity and I am loading simple url into webview.

my Webview settings are as

wbView = (WebView) findViewById(R.id.wbView);
        wbView.setKeepScreenOn(true);
        wbView.getSettings().setJavaScriptEnabled(true);
        wbView.getSettings().setDomStorageEnabled(true);
        wbView.getSettings().setBuiltInZoomControls(true);
        wbView.setInitialScale(100);
        // wbView.getSettings().setUseWideViewPort(true);
        wbView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
        wbView.setWebViewClient(new MyWebViewClient());

and MyWebViewClient() contains

private class MyWebViewClient extends WebViewClient {
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            prgBar.setVisibility(View.GONE);
        }

        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler,
                SslError error) {
            Log.e("Error VAGARO", error.toString());
            prgBar.setVisibility(View.GONE);
            handler.proceed();
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return false;
        }
    }

I am loading two HTML files from the Asset in the same webview its working fine but unable to load dynamic url.

I Google and find some posts on http://code.google.com/p/android/issues/detail?id=21177

My logcat shows me

05-09 13:33:30.187: W/webcore(20054): java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up.
05-09 13:33:30.187: W/webcore(20054):   at android.webkit.WebViewCore$EventHub.removeMessages(WebViewCore.java:1683)
05-09 13:33:30.187: W/webcore(20054):   at android.webkit.WebViewCore$EventHub.access$7900(WebViewCore.java:926)
05-09 13:33:30.187: W/webcore(20054):   at android.webkit.WebViewCore.removeMessages(WebViewCore.java:1795)
05-09 13:33:30.187: W/webcore(20054):   at android.webkit.WebView.sendOurVisibleRect(WebView.java:2917)
05-09 13:33:30.187: W/webcore(20054):   at android.webkit.ZoomManager.setZoomScale(ZoomManager.java:593)
05-09 13:33:30.187: W/webcore(20054):   at android.webkit.ZoomManager.access$1700(ZoomManager.java:49)
05-09 13:33:30.187: W/webcore(20054):   at android.webkit.ZoomManager$PostScale.run(ZoomManager.java:984)
05-09 13:33:30.187: W/webcore(20054):   at android.os.Handler.handleCallback(Handler.java:605)
05-09 13:33:30.187: W/webcore(20054):   at android.os.Handler.dispatchMessage(Handler.java:92)
05-09 13:33:30.187: W/webcore(20054):   at android.os.Looper.loop(Looper.java:137)
05-09 13:33:30.187: W/webcore(20054):   at android.app.ActivityThread.main(ActivityThread.java:4424)
05-09 13:33:30.187: W/webcore(20054):   at java.lang.reflect.Method.invokeNative(Native Method)
05-09 13:33:30.187: W/webcore(20054):   at java.lang.reflect.Method.invoke(Method.java:511)
05-09 13:33:30.187: W/webcore(20054):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-09 13:33:30.187: W/webcore(20054):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-09 13:33:30.187: W/webcore(20054):   at dalvik.system.NativeStart.main(Native Method)

Suggest me the change that I should make.

Update

I found that if I'll pass any url like "www.facebook.com" then its giving me this error, but if I'll replace it with "https://www.facebook.com" then its working fine.

like image 252
Vishal Khakhkhar Avatar asked May 09 '12 08:05

Vishal Khakhkhar


2 Answers

The issue I found was because of the url without http:// or https://. So I appended this tag if the url doesn't contains http:// or https://.

like image 82
Vishal Khakhkhar Avatar answered Oct 14 '22 16:10

Vishal Khakhkhar


In my case, I fixed it by changing the order. I put the loadUrl before getSettings()

Working snippet below,

mWebView = (WebView) findViewById(R.id.web_view);

// load file
mWebView.loadUrl(SERVER_URL);
mWebView.getSettings().setJavaScriptEnabled(true);

Hope this helps someone..

like image 44
Vijay C Avatar answered Oct 14 '22 14:10

Vijay C