2

以下是我从 Google Play 收到的消息。

在此处输入图像描述

阅读该消息后,我查看了Google 帮助中心文章。对于我的想法,这应该与 of 的类WebViewClient及其一些方法有关,例如onReceivedSslError,SslErrorHandler.proceed()SslErrorHandler.cancel(). 然后在我的项目中,我尝试搜索一些关键字,例如WebViewClient,SslErrorHandleronReceivedSslError. 我也得到了Nothing to show的结果。

有什么建议可以解决这个问题吗?

4

1 回答 1

1

显示带有继续和取消的弹出窗口或对话框。
继续 handler.proceed()
取消 handler.cancel()

我们需要询问用户,当这个错误发生时,继续或停止。

像这样

val builder = AlertDialog.Builder(cntx)
        var message = "SSL Certificate error."
        when (error?.primaryError) {
            SslError.SSL_UNTRUSTED -> message = "The certificate authority is not trusted."
            SslError.SSL_EXPIRED -> message = "The certificate has expired."
            SslError.SSL_IDMISMATCH -> message = "The certificate Hostname mismatch."
            SslError.SSL_NOTYETVALID -> message = "The certificate is not yet valid."
        }
        message += " Do you want to continue anyway?"

        builder.setTitle("SSL Certificate Error")
        builder.setMessage(message)
        builder.setPositiveButton(
            "continue"
        ) { dialog, which -> handler?.proceed() }
        builder.setNegativeButton(
            "cancel"
        ) { dialog, which -> handler?.cancel() }
        val dialog = builder.create()
        dialog.show()
于 2021-05-18T10:54:19.363 回答