首页 > 解决方案 > android recaptcha 安全网检测对话框取消

问题描述

我正在尝试检测重新验证取消对话框,但 addOnCancelListener 不起作用,代码如下:

   SafetyNet.getClient(this).verifyWithRecaptcha(getString(R.string.API_SITE_KEY))
            .addOnSuccessListener(this) { response ->

                progressBar.visibility=View.GONE
                if (!response.tokenResult.isEmpty()) {
                    sendMessage()

                }else{
                    Toast.makeText(applicationContext,"1111",Toast.LENGTH_LONG).show()
                    }
            }
            .addOnFailureListener(this) { e ->
                Toast.makeText(applicationContext,"2222",Toast.LENGTH_LONG).show()
          if (e is ApiException) {
                    Log.wtf("captcha_contact",("Error message: " + 
               CommonStatusCodes.getStatusCodeString(e.statusCode)))
                } else {
                    Log.wtf("captcha_contact", "Unknown type of error: " + e.message)
                }
            }
            .addOnCanceledListener (this){

                Toast.makeText(applicationContext,"33333",Toast.LENGTH_LONG).show()
            }

我还尝试防止用户在加载验证码任务对话框时触摸屏幕,但始终触摸对话框外部会关闭对话框,所以请任何想法检测取消或防止用户在加载验证码时触摸外部

标签: androidkotlinrecaptcha

解决方案


推荐阅读