我正在Android O中从IntentService动态创建Webview,并遇到以下崩溃:
java.lang.RuntimeException: 在执行doInBackground()时发生错误 at android.os.AsyncTask$3.done(AsyncTask.java:353) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.RuntimeException: 尚未覆盖UI线程 at org.chromium.base.ThreadUtils.getUiThreadHandler(ThreadUtils.java:5) at org.chromium.base.ThreadUtils.runningOnUiThread(ThreadUtils.java:45) at com.android.webview.chromium.WebViewChromiumFactoryProvider.C(WebViewChromiumFactoryProvider.java:149) at com.android.webview.chromium.WebViewChromiumFactoryProvider.l(WebViewChromiumFactoryProvider.java:262) at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:29) at android.webkit.WebView.<init>(WebView.java:658) at android.webkit.WebView.<init>(WebView.java:588) at android.webkit.WebView.<init>(WebView.java:571) at android.webkit.WebView.<init>(WebView.java:558) at android.webkit.WebView.<init>(WebView.java:548)
这在早期版本的Android中运行良好。有什么想法吗?
java.lang.RuntimeException: 在执行doInBackground()时发生错误 at android.os.AsyncTask$3.done(AsyncTask.java:353) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.RuntimeException: 尚未覆盖UI线程 at org.chromium.base.ThreadUtils.getUiThreadHandler(ThreadUtils.java:5) at org.chromium.base.ThreadUtils.runningOnUiThread(ThreadUtils.java:45) at com.android.webview.chromium.WebViewChromiumFactoryProvider.C(WebViewChromiumFactoryProvider.java:149) at com.android.webview.chromium.WebViewChromiumFactoryProvider.l(WebViewChromiumFactoryProvider.java:262) at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:29) at android.webkit.WebView.<init>(WebView.java:658) at android.webkit.WebView.<init>(WebView.java:588) at android.webkit.WebView.<init>(WebView.java:571) at android.webkit.WebView.<init>(WebView.java:558) at android.webkit.WebView.<init>(WebView.java:548)
这在早期版本的Android中运行良好。有什么想法吗?
context.runOnUiThread(new Runnable() {public void run() { /* your code here */ }});
(将/your code here/替换为创建WebView的代码)。 - EJKrunOnUiThread
是Activity
的一个方法,而不是Context
的。在服务的上下文中没有相关性。 - Cigogne Eveillée