How to intercept url loads in WebView (android)?

后端 未结 2 1217
清酒与你
清酒与你 2020-12-17 19:35

I have a WebView in which I load a page with a custom link (like app://action). I registered the url schemes in the manifest file and when I click on the link, the onResume(

2条回答
  •  一个人的身影
    2020-12-17 20:29

    Use WebViewClient.shouldOverrideUrlLoading instead.

    public boolean shouldOverrideUrlLoading(WebView view, String url){
        // handle by yourself
        return true; 
    }
    

    WebViewClient Reference

    Updates: Method shouldOverrideUrlLoading(WebView, String) is deprecated in API level 24. Use shouldOverrideUrlLoading(WebView, WebResourceRequest) instead.

提交回复
热议问题