显示带有继续和取消的弹出窗口或对话框。
继续 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()