The android tutorial USES webview to access https's url to handle the sslerror example
- 2020-05-24 06:09:29
- OfStack
In Android, WebView is a control for the local application of load http and https web pages. By default, through loadUrl (String url) method, and can be smoothly load such as http: / / www baidu. com page. But when load ssl layer https page, such as https: / / money. 183. com. cn /, if the site safety certificate authentication, cannot be obtained in Android WebView becomes a blank page, and would not like PC jump out of a risk prompt box in the browser. So we have to deal with that.
The processing of Android USES two classes
import android.net.http.SslError;
import android.webkit.SslErrorHandler;
The specific usage is as follows:
WebView wv = (WebView) findViewById(R.id.webview);
wv.setWebViewClient(new WebViewClient(){
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error){
//handler.cancel(); The default processing, WebView Go to blank page
//handler.process(); Accept the certificate
//handleMessage(Message msg); Other processing
}
If you simply accept all certificates, simply call the process() method.