我想知道是否有人可以帮助我?
我想为Android开发一个应用程序(webview),但它曾经使用http://链接但不知何论https://链接无法打开。当我使用普通浏览器访问普通网站时,它会要求我允许继续使用证书。
我现在的问题是如何允许证书并查看HTTPS?
我会在我的webview活动下面发布我的源代码,提前感谢:)
package im.testing.a.cool.app;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class WebPageLoader extends Activity
{
final Activity activity = this;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.main);
WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
activity.setTitle("Grabbing the bits and the bytes..");
activity.setProgress(progress * 100);
if(progress == 100)
activity.setTitle(R.string.app_name);
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
// Handle the error (does the ssl goes hier?)
engine = (WebView) findViewById(R.id.my_webview);
engine.setWebViewClient(new WebViewClient() {
public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
handler.proceed() ;
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
webView.loadUrl("https://website.willnot.open");
}
}