2024-03-19

        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)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 终于可以休假一段时间了,希望这段时间暴富暴美暴瘦,如果能中个彩票,或许我真的可以勇敢到辞职。 有没有人可以推荐一家...
    我就是开心呦就是开心阅读 75评论 0 2
  • 1. 父子通信 (1)setup函数提供俩个参数,第一个参数为props,第二个参数为一个对象context (2...
    IT成长空间阅读 83评论 0 0
  • 三毛说:“一个太过文艺的人,注定不会太快乐,心里有爱、有善良,骨子里住着孩子般的纯真,但也往往多愁善感,容易感知美...
    李小讷阅读 111评论 0 4
  • #遇见幸福 03.18 晚课 补 我看到我的进步,相信相信的力量,我相信我的孩子不会差,我相信这世界是美好的,我相...
    七七妈妈成长日记阅读 60评论 0 0
  • 你知道怎样做一斤都匀毛尖茶吗? 一斤毛尖茶大约有65000个芽头,也就是要采65000次芽,如果按平均3秒钟采一个...
    聆听镜看阅读 78评论 0 0