一. shouldOverrideUrlLoading的含义
Sdk中的解释
public boolean shouldOverrideUrlLoading (WebView view, String url)Added in API level 1.
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. This method is not called for requests using the POST "method".
这里面一共蕴含着三层意思:
1.若没有设置 WebViewClient 则由系统(Activity Manager )处理该 url,通常是使用浏览器打开或弹出浏览器选择对话框。
2.若设置 WebViewClient 且该方法返回 true ,则说明由应用的代码处理该 url,WebView 不处理。
3.若设置 WebViewClient 且该方法返回 false,则说明由 WebView 处理该 url,即用 WebView 加载该 url