WebViewClient
WebViewClient中的常用方法有:
- onPageFinished(WebView view, String url)
- onPageStarted(WebView view, String url, Bitmap favicon)
- onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
- shouldInterceptRequest(WebView view, String url)
- shouldOverrideUrlLoading(WebView view, String url)
等,以上方法都是webview中请求过程等事件的处理方法.
WebChromeClient
WebChromeClient中的常用方法有:
- onCloseWindow(WebView window)
- onConsoleMessage(ConsoleMessage consoleMessage)
- onJsAlert(WebView view, String url, String message, JsResult result)
- onJsConfirm(WebView view, String url, String message, JsResult result)
- onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result)
- onPermissionRequest(PermissionRequest request)
- onReceivedIcon(WebView view, Bitmap icon)
- onReceivedTitle(WebView view, String title)
- onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
等,以上方法都是webview和用户之间有交互的一些方法,如JS弹窗,文件选择弹窗,窗口关闭等