Tuesday, 25 August 2015

android webview error : A WebView method was called on thread 'JavaBridge'.






W/System.err﹕ java.lang.RuntimeException: java.lang.Throwable: A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {41a9a440} called on Looper (JavaBridge, tid 17681) {41ca74f8}, FYI main Looper is Looper (main, tid 1) {41a9a440})
08-25 10:33:21.702  22739-22823/xxx.hot W/System.err﹕ at android.webkit.WebView.checkThread(WebView.java:2073)
08-25 10:33:21.702  22739-22823/xxx.hot W/System.err﹕ at android.webkit.WebView.postUrl(WebView.java:809)
08-25 10:33:21.702  22739-22823/xxx.hot W/System.err﹕ at xxx.WebViewController$1JavaScriptInterface.handleConfirmJson(WebViewController.java:186)
08-25 10:33:21.702  22739-22823/xxx.hot W/System.err﹕ at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
08-25 10:33:21.702  22739-22823/xxx.hot W/System.err﹕ at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:27)
08-25 10:33:21.702  22739-22823/xxx.hot W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:102)
08-25 10:33:21.702  22739-22823/xxx.hot W/System.err﹕ at android.os.Looper.loop(Looper.java:136)
08-25 10:33:21.702  22739-22823/xxx.hot W/System.err﹕ at android.os.HandlerThread.run(HandlerThread.java:61)
08-25 10:33:21.702  22739-22823/xxx.hot W/System.err﹕ Caused by: java.lang.Throwable: A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {41a9a440} called on Looper (JavaBridge, tid 17681) {41ca74f8}, FYI main Looper is Looper (main, tid 1) {41a9a440})
08-25 10:33:21.702  22739-22823/xxx.hot W/System.err﹕ at android.webkit.WebView.checkThread(WebView.java:2063)
08-25 10:33:21.702  22739-22823/xxx.hot W/System.err﹕ ... 7 more

Solution:

in your javaBridge function call loadUrl of postUrl like this:

myWebView.post(new Runnable() {
    @Override
    public void run() {
        myWebView.loadUrl("file:///android_asset/test1.html");    }
});

http://stackoverflow.com/questions/21955593/android-webview-loadurl-wont-load-another-webpage





No comments:

Post a comment