更新时间:2023-08-31 21:28:34
您可以使用 webClient 并实现 shouldOverrideUrlLoading 来拦截所有 url在 WebView 加载它们之前.
You could use a webClient and implement shouldOverrideUrlLoading to intercept all the urls before the WebView loads them.
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// Here put your code
Log.d("My Webview", url);
// return true; //Indicates WebView to NOT load the url;
return false; //Allow WebView to load url
}
});