【发布时间】:2012-07-23 01:34:23
【问题描述】:
是的,我知道 stopLoading() 的文档说“停止当前负载。”
但是当我尝试使用它在加载新页面之前停止加载当前正在进行的页面时,它似乎没有表现as desired:
07-24 12:53:30.177: V/WebView.loadUrl: http://www.google.com
07-24 12:53:30.227: V/WebViewClient.onPageStarted: http://www.google.com
===> WebView.stopLoading() called here <====
07-24 12:53:31.917: V/WebView.loadUrl: http://www.stackoverflow.com
07-24 12:53:32.697: V/WebViewClient.onPageFinished: http://www.google.com
07-24 12:53:32.767: V/WebViewClient.onPageStarted: http://www.stackoverflow.com
07-24 12:53:33.587: V/WebViewClient.onPageFinished: http://www.stackoverflow.com
正如您在日志中看到的那样,第一个 loadUrl() 的 WebViewClient.onPageFinished() 被调用,尽管 WebView.stopLoading() 被调用大约 1 秒前。
这是为什么呢?
stopLoading() 的真正作用是什么?
【问题讨论】:
-
我猜它只是设置了一个标志来告诉 WebView 不要运行任何钩子,如 onPageFinished 等。我认为它实际上不会停止网络连接。
标签: android webview android-webview webviewclient