1.采用鸿蒙二维码扫描,可识别CAD二维码和复杂二维码
// scankitSDK华为鸿蒙扫描 implementation 'com.huawei.hms:scanplus:1.3.1.300'
//华为仓库 maven { url 'https://developer.huawei.com/repo/'}
使用非常简单,扫描二维码只需要
private fun startScan() { XXPermissions.with(this) .permission(Permission.CAMERA) .request { _, all -> if (all) { ScanUtil.startScan( this@ScanActivity, REQUEST_CODE_SCAN, HmsScanAnalyzerOptions.Creator().create() ) } } } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (resultCode != RESULT_OK || data == null) { return } val obj: HmsScan? = data.getParcelableExtra(ScanUtil.RESULT) if(obj != null) { val resultStr = obj.getOriginalValue() tvScanResult.text = resultStr } }
demo及其详细文档:华为鸿蒙扫描文档