由于 SSL 错误,我试图在我的一项活动中加载到 web 视图中的 URL 显示为空白。
我曾尝试使用网络安全配置 XML 文件夹,但我不确定我在做什么。任何帮助将不胜感激。
在调试时,当我加载 Google.com 作为 webview 中的 URL 时,页面加载正常。然后,当我尝试搜索特定站点时,它就在那里,但是当我单击它时,我在 Android Studio 的运行日志中收到了 SSL 错误。
public class About_ALC extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about__alc);
final WebView webview = (WebView) findViewById(R.id.web_about_alc);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
webview.setWebViewClient(new WebViewClient());
webview.setWebChromeClient(new WebChromeClient());
webview.loadUrl("https://andela.com/alc/");
}
Run Code Online (Sandbox Code Playgroud)
我在 Android Studio 中收到的错误消息是:
“E/chromium: [ERROR:ssl_client_socket_impl.cc(947)] 握手失败;返回 -1,SSL 错误代码 1,net_error -202”