Android WebView and network-security-configuration

╄→гoц情女王★ 提交于 2019-12-04 18:43:46

[SOLVED]

In AndoridManifest.xml I declared

 <application
        android:networkSecurityConfig="@xml/network_security_config"
 ...
 </application>

Editor warned about a problem related to the SDK version but I didn't see it. This is the warning.

[SOLUTION]

Add this tools:targetApi="n" to the Manifest like the following:

<application
    android:networkSecurityConfig="@xml/network_security_config"
    ...
    tools:targetApi="n">

[EDIT]

SSL error is handled in public void onReceivedSslError(...) of WebViewClient (See the following code)

  webView.setWebViewClient(new WebViewClient() {
            public void onReceivedSslError(WebView view, 
                final SslErrorHandler handler, SslError error) {
                     //HANDLE HERE THE ERROR!!!
                ...
            }
        ...
  });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!