java.lang.RuntimeException: java.lang.Throwable: A WebView method was called on thread 'JavaBridge'.
来源:互联网 发布:excel表格数据合并计算 编辑:程序博客网 时间:2024/05/16 19:21
错误代码
FATAL EXCEPTION: JavaBridgeProcess: violetjack.smartinfusion, PID: 31227java.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) {4186a978} called on Looper (JavaBridge, tid 385) {41a24830}, FYI main Looper is Looper (main, tid 1) {4186a978})at android.webkit.WebView.checkThread(WebView.java:2082)at android.webkit.WebView.loadUrl(WebView.java:803)...
错误原因
由于我在webview加载页面时是这么写的
private void callChangeStartTime(final String time){ String call = "javascript:changeStartTime(\"" + time + "\")"; wvContent.loadUrl(call);}
一开始在4.2的机器上没有这个问题,到4.4的机器上就出了这个问题。
解决方案
在Stackoverflow上找到了正解http://stackoverflow.com/questions/22607657/webview-methods-on-same-thread-error
runOnUiThread(new Runnable() { @Override public void run() { final WebView webView = (WebView) findViewById(R.id.map); webView.loadDataWithBaseURL(...); }});
就是将webview的loadUrl
方法写在runOnUiThread
中即可解决问题。就如我做的那样~
private void callChangeStartTime(final String time){ runOnUiThread(new Runnable() { @Override public void run() { String call = "javascript:changeStartTime(\"" + time + "\")"; wvContent.loadUrl(call); } });}
1 0
- java.lang.RuntimeException: java.lang.Throwable: A WebView method was called on thread 'JavaBridge'.
- android开发 WebViewjava.lang.Throwable: A WebView method was called on thread 'JavaBridge'. All WebVie
- java.lang.Throwable: Warning: A WebView methods must be called on the same thread.
- 异常A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same
- A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same t
- Android异常解决--A WebView method was called on thread 'JavaBridge'. All WebView methods must be called
- java.lang.RuntimeException: Method called after release()
- java.lang.RuntimeException: Method called after release()
- java.lang.RuntimeException: Method called after release()
- java.lang.RuntimeException: Method called after release()
- java.lang.Throwable: Explicit termination method 'close' not called
- Android 在使用webview报错 A WebView method was called on thread 'Thread-2599'
- java.lang.RuntimeException: invoke method
- java.lang.RuntimeException: Handler{405c1180} sending message to a Handler on a dead thread
- java.lang.RuntimeException: Camera is being used after Camera.release() was called
- java.lang.RuntimeException: Camera is being used after Camera.release() was called
- Android锁屏出现java.lang.RuntimeException: Camera is being used after Camera.release() was called
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- 使用wait的时候,什么要使用while
- Problem 10 Summation of primes (素数和)
- 初探git
- 第八章-项目质量管理
- ServletActionContext
- java.lang.RuntimeException: java.lang.Throwable: A WebView method was called on thread 'JavaBridge'.
- java主方法main()方法为什么要必须是静态static的?
- Linux 网桥配置命令:brctl
- RGBA背景颜色半透明全兼容的做法
- Looper.getMainLooper()
- iOS app 发布错误 ERROR ITMS-90167: "No .app bundles found in the package"
- 教你如何分辨用户是用手机还是电脑访问你的网站
- JVM Internals
- 2016/10/26 c语言tcp传输文件的理解