项目中用到java和js交互,js调用java方法,让webView刷新网页,异常信息如下:
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) {c44f280} called on Looper (JavaBridge, tid 26651) {a2bc55}, FYI main Looper is Looper (main, tid 1) {c44f280})
解决办法:
在Activity里面的调用方法执行代码采用这种方式写:
/**
* 刷新webView 我的商品
*/
public void refreshWebViewGoods() {
runOnUiThread(new Runnable() {
@Override
public void run() {
goods.refurbishWebViewGoods();
}
});
}