的WebView线程永远不会停止(WebViewCoreThread,CookieSyncManager,HTTP [0-3]) [英] WebView threads never stop (WebViewCoreThread, CookieSyncManager, http[0-3])

查看:196
本文介绍了的WebView线程永远不会停止(WebViewCoreThread,CookieSyncManager,HTTP [0-3])的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用web视图显示在我们的应用程序的One一些互联网内容 活动。
的问题是,当用户切换这一活动的, WebView功能的线程保持运行!
有问题的线程是:

I use a WebView to display some internet content on one of our app's Activities.
The problem is that when the user switches out of this activity, WebView's threads keep running!
The problematic threads are:

Thread [<17> WebViewCoreThread] (Running)
Thread [<25> CookieSyncManager] (Running)
Thread [<19> http0] (Running)
Thread [<29> http1] (Running)
Thread [<31> http2] (Running)
Thread [<33> http3] (Running)

暂停这些线程中的每一个,并检查它是什么忙于做:

Pausing each one of these threads, and checking what it is busy doing:

Thread [<17> WebViewCoreThread] (Suspended)
    Object.wait(long, int) line: not available [native method]
    MessageQueue(Object).wait() line: 288
    MessageQueue.next() line: 148
    Looper.loop() line: 110
    WebViewCore$WebCoreThread.run() line: 471
    Thread.run() line: 1060

Thread [<25> CookieSyncManager] (Suspended)
    Object.wait(long, int) line: not available [native method]
    MessageQueue(Object).wait(long) line: 326
    MessageQueue.next() line: 144
    Looper.loop() line: 110
    CookieSyncManager(WebSyncManager).run() line: 90
    Thread.run() line: 1060

Thread [<19> http0] (Suspended)
    Object.wait(long, int) line: not available [native method]
    RequestQueue(Object).wait() line: 288
    ConnectionThread.run() line: 93

我不知道我怎么能告诉尺蠖在其中每个线程退出。

I wonder how can I tell the Looper in each of those threads to quit.

我打过电话 webView.destroy()在活动的的onPause()的方法, 但它有没有影响。
当我禁用呼吁在web视图打开一个网页 ( webView.loadUrl(...)),这些线程自然没有启动, 因此,在离开活动后不留。

I tried calling webView.destroy() in the activity's onPause() method, but it had no influence.
When I disable the call for opening a web page in the webView ( webView.loadUrl(...) ), those threads naturally are not started, and therefore don't stay on after leaving the activity.

任何想法如何,我可以离开后的WebView 的线程停止 他们的活动呢?

Any ideas as to how I can make WebView's threads stop after leaving their activity?

推荐答案

您应该能够停止/调用的onPause / onResume上的WebView恢复这些线程。

You should be able to stop / resume these threads by calling the onPause / onResume on the webview.

然而,这些方式隐藏的,所以你需要通过反射来做到这一点。下面code为我工作:

Those are however hidden, so you will need to do it through reflection. The following code worked for me:

Class.forName("android.webkit.WebView").getMethod("onPause", (Class[]) null).invoke(webView, (Object[]) null);

在哪里web视图是web视图的实例。

Where webView is the instance of WebView.

另请参见:<一href="http://$c$c.google.com/p/android/issues/detail?id=10282">http://$c$c.google.com/p/android/issues/detail?id=10282

这篇关于的WebView线程永远不会停止(WebViewCoreThread,CookieSyncManager,HTTP [0-3])的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆