Android异常解决--A WebView method was called on thread 'JavaBridge'. All WebView methods must be called

Android异常解决--A WebView method was called on thread 'JavaBridge'. All WebView methods must be called 


android端调用js. 使用webView.loadUrl("javascript: alert(" + data +")"); 出现异常.

异常log如下:

 W/WebView(2088): 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) {b3dbcb18} called on Looper (JavaBridge, tid 120) {b44a1af8}, FYI main Looper is Looper (main, tid 1) {b3dbcb18})
    W/WebView(2088):     at android.webkit.WebView.checkThread(WebView.java:2063)
    W/WebView(2088):     at android.webkit.WebView.loadUrl(WebView.java:794)
    W/WebView(2088):     at com.ue.oa.activity.XFormActivity.alert(XFormActivity.java:180)
    W/WebView(2088):     at com.ue.oa.activity.XFormActivity$FormActions.save(XFormActivity.java:193)
    W/WebView(2088):     at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
    W/WebView(2088):     at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:27)
    W/WebView(2088):     at android.os.Handler.dispatchMessage(Handler.java:102)
    W/WebView(2088):     at android.os.Looper.loop(Looper.java:136)
解决方法:

     webView.post(new Runnable() {
            @Override
            public void run() {
                webView.loadUrl("javascript: alert(" + data +")");
            }
    });



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值