Android Webview shouldOverrideUrlLoading method

前端 未结 2 1121
夕颜
夕颜 2021-01-08 00:14

When is shouldOverrideUrlLoading method called?

webView.setWebViewClient(new WebViewClient(){
    @Override
    public boolean shouldOverrideUrl         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-08 00:39

    1. It does however, get called when the WebView to load a different URL from the one the user had requested.

    2. Calling loadUrl() will also trigger the shouldOverrideUrlLoading() method. (Only when a new url is about to be loaded.)

    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.

    Ref : public boolean shouldOverrideUrlLoading (WebView view, String url)

提交回复
热议问题