HMS-Core / hms-scan-demo

Sample code for demonstrating Huawei HMS ScanKit capabilities. It illustrates how to help developers quickly build code scanning capabilities.

Home Page:https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/scan-introduction-4?ha_source=hms1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

通过 startActivityForResult 处理方式 google已经不再推荐,希望能支持新的ActivityResultLauncher来开启扫描界面

jyh149129 opened this issue · comments

如题

您好,方便留个微信吗,我们可以线下沟通

或者您也可以添加我们技术人员的微信:a2743979839

commented

遇到同样的问题,请问如何解决?

private val launcher =
        registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
            if (it.resultCode == Activity.RESULT_OK) {
                when (val obj: Parcelable? = it.data?.getParcelableExtra(ScanUtil.RESULT)) {
                    is HmsScan -> {
                    }
                }
            }
        }
launcher. Launch(
                    Intent(
                        requireContext(),
                        ScanKitActivity::class.java
                    ).putExtra(
                        "ScanFormatValue",
                        HmsScanAnalyzerOptions.Creator().setHmsScanTypes(HmsScan.ALL_SCAN_TYPE)
                            .create().mode
                    )
                )
commented

谢谢