/** * Description: handle https * Created by Michael Lee on 12/6/16 08:38 */ @Override publicvoidonReceivedSslError(WebView view, SslErrorHandler handler, SslError error){ handler.proceed(); }
if (!checkUrlValid(decoded_url)) { super.shouldOverrideUrlLoading(view,url); Log.d("WebView","Handle url with system~~"); returnfalse; } else { // Do your special things returntrue; } }
@Override publicvoidonPageStarted(WebView view, String url, Bitmap favicon){ Log.d("WebView", "onPageStarted : " + url); if (!checkUrlValid(url)) { super.onPageStarted(view,url,favicon); Log.d("WebView","Handle url with system~~"); return; } else { // Do your special things } }
@Override publicvoidonPageFinished(WebView view, String url){ Log.d("WebView","onPageFinished : " + url); if (!checkUrlValid(url)) { super.onPageFinished(view,url); Log.d("WebView","Handle url with system~~"); return; } else { // Do your special things } } });
/** * Description: check if the url is valid, such as taobao's url like this "https://s.click.tao" * or "s.click.tmall.com", can not modify the onPageStart method * Created by Michael Lee on 12/30/16 16:08 * @param aUrl webview's url * @return true if url is NOT contains "s.click" */ privatebooleancheckUrlValid(String aUrl){ boolean result = true; if (aUrl == null || aUrl.equals("") || !aUrl.contains("http")) { returnfalse; } if (aUrl.contains("s.click")) { result = false; } return result; }