1.前言
前两篇我们讲解了
Android WebView开发(一)–WebView的使用介绍;
Android WebView开发(二)–WebSettings使用详解;
想要了解的可以去看看。
今天是WebView开发的第三篇–WebViewClient 与WebChromeClient的使用。
2.WebViewClient类
2.1 WebViewClient作用:
WebViewClient主要用来处理请求事件和在合适的时候回调进行一些逻辑处理
2.2 WebViewClient 常用方法 :
2.2.1 shouldOverrideUrlLoading()方法
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".
*
* @param view The WebView that is initiating the callback.
* @param url The url to be loaded.