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.
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.
Any ideas as to how I can make WebView
's threads stop after leaving
their activity?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…