这是我的代码。正如您在第一个代码块中看到的,我将WebView对象“myWebView”设置为继承自WebViewClient的WebViewClient“SSLTolerantWebViewClient”,但是没有WebViewClient方法出现,因此我不能使用onPageFinished。有什么想法吗?
public class WebAuth extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_auth);
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebViewClient(new SSLTolerantWebViewClient());
myWebView.loadUrl("example.com");
//myWebView.onPageFinished(args); This method doesn't appear, nor do any other WebViewClient methods
// other basic activity methods
}
其他课程:
public class SSLTolerantWebViewClient extends WebViewClient {
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed(); // Ignore SSL certificate errors
}
}
答案 0 :(得分:0)
不确定我是否已经弄明白或只是找到了解决方法。我所做的就是创建一个WebViewClient对象并使用它的方法。代码现在看起来像:
public class WebAuth extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_auth);
WebView myWebView = (WebView) findViewById(R.id.webview);
SSLTolerantWebViewClient n = new SSLTolerantWebViewClient();
myWebView.setWebViewClient(n);
myWebView.loadUrl("example.com");
n.onPageFinished(myWebView, "example.com"); This method doesn't appear, nor do any other WebViewClient methods
// other basic activity methods
}