gpt4 book ai didi

android - WebViewClient - onPageStarted() vs shouldOverrideUrlLoading()?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:40:12 26 4
gpt4 key购买 nike

我正在使用 WebViewClient。我们是否应该看到 onPageStarted() 回调总是与 shouldOverrideUrlLoading() 回调配对?如果我在我的 WebView 中加载 example.com,我们是否应该看到这两种方法都被回调了?来自文档:

onPageStarted()

Notify the host application that a page has started loading. This method is called once for each main frame load so a page with iframes or framesets will call onPageStarted one time for the main frame. This also means that onPageStarted will not be called when the contents of an embedded frame changes, i.e. clicking a link whose target is an iframe.

shouldOverrideUrlLoading()

Give the host application a chance to take over the control when a new url is about to be loaded in the current WebView. If WebViewClient is not provided, by default WebView will ask Activity Manager to choose the proper handler for the url. If WebViewClient is provided, return true means the host application handles the url, while return false means the current WebView handles the url.

我在每个方法中都放置了一个日志语句,我发现它们并不总是配对在一起。在什么情况下它们不会?

谢谢

http://developer.android.com/reference/android/webkit/WebViewClient.html

最佳答案

我知道这个问题很老,但无论如何都要回答。 AFAIK,将为页面中的每个 url 调用 shouldOverrideUrlLoading(),而 onPageStart() 将仅为页面的顶部 url 调用。

关于android - WebViewClient - onPageStarted() vs shouldOverrideUrlLoading()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9808420/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com