WebViewClient not calling shouldOverrideUrlLoading

后端 未结 10 2358
逝去的感伤
逝去的感伤 2020-12-15 18:44

The problem is rather simple. In the application we want to keep track of the current url being displayed. For that we use shouldOverrideUrlLoading callback fr

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-15 19:25

    Maybe this helps someone, although the signature in the question is correct, but Android Studio suggests the following method signature:

    public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
    

    which then never called. It took me a while to notice that the right signature is:

    public boolean shouldOverrideUrlLoading(WebView view, String url) {
    

    Sorry if this not 100% fit the question, but I believe this may help someone in the same situation. It's not always easy to notice that the second parameter is different.

提交回复
热议问题