Difference between shouldoverrideurlloading and shouldinterceptrequest?

前端 未结 2 1660
失恋的感觉
失恋的感觉 2021-01-31 09:44

Anyone please tell me the difference between methods public WebResourceResponse shouldInterceptRequest (WebView view, WebResourceRequest request) and public b

2条回答
  •  长情又很酷
    2021-01-31 10:12

    I believe that shouldOverrideUrlLoading is invoked when a new page is being loaded into the webview, so for example, when you do your initial:

    webview.loadUrl( "file:///android_asset/web/index.html" );      
    

    YOur shouldOverrideUrlLoading will get invoked, and it will get invoked again if user clicks on a link to browse to a new page.

    shouldInterceptRequest should get called for all requests made within the current page, eg. when I HTML import fonts I see shouldInterceptRequest getting called, or when the webView tries to load images on my page it gets called (but I'm not seeing it called for ajax requests, so I'm still a bit confused).

提交回复
热议问题