美文网首页
2024-03-19

2024-03-19

作者: zivxia | 来源:发表于2024-03-18 16:32 被阅读0次
            val okHttpClient = OkHttpClient.Builder().apply {
                retryOnConnectionFailure(true)
                callTimeout(60, TimeUnit.SECONDS)
                connectTimeout(30, TimeUnit.SECONDS)
                readTimeout(30, TimeUnit.SECONDS)
                writeTimeout(30, TimeUnit.SECONDS)
                addInterceptor(
                    Interceptor { chain: Interceptor.Chain ->
                        // Retry on exception (network error) and 5xx
                        val request = chain.request()
                        for (attempt in 1..3) {
                            try {
                                val response = chain.proceed(request)
                                if (response.code < 500) {
                                    return@Interceptor response
                                }
                            } catch (e: Exception) {
                                // Network failures end up here. These will be retried
                            }
                        }
                        return@Interceptor chain.proceed(request)
                    },
                )
            }.build()
            SmileID.initialize(apiKey = "8e177104-ea19-4f09-b0cf-f49729307fdb",context, useSandbox = true, enableCrashReporting = false, okHttpClient = okHttpClient)
    
            fragment_container = findViewById(R.id.fragment_container)
            var userId = DetectUtils.randomUserId()
            var jobId = DetectUtils.randomJobId()
            var allowAgentMode = true
            var smartSelfieFragment = SmartSelfieEnrollmentFragment.newInstance(userId,jobId,allowAgentMode)
            supportFragmentManager.setFragmentResultListener(
                SmartSelfieEnrollmentFragment.KEY_REQUEST,
                this
            ){ requestKey: String?, result: Bundle ->
                val smartSelfieResult = SmartSelfieEnrollmentFragment.resultFromBundle(result)
                if (smartSelfieResult is SmileIDResult.Success<SmartSelfieResult>){
                    val selfieFile = smartSelfieResult.data.selfieFile;
                    var livenessaFlag = smartSelfieResult.data.selfieFile
                    LogUtils.e("wanggang","-------------------------------"+smartSelfieResult.toString())
                }else if (smartSelfieResult is SmileIDResult.Error ){
                    LogUtils.e("wanggang","-------------------------------"+smartSelfieResult.toString())
                }
    
                supportFragmentManager
                    .beginTransaction()
                    .remove(smartSelfieFragment)
                    .commit()
                showProductFragment(false)
            }
            supportFragmentManager
                .beginTransaction()
                .replace(R.id.fragment_container, smartSelfieFragment)
                .commit()
            showProductFragment(true)
    

    相关文章

      网友评论

          本文标题:2024-03-19

          本文链接:https://www.haomeiwen.com/subject/lnczzdtx.html