当前位置:   article > 正文

【FAQ】HarmonyOS SDK 闭源开放能力 —Scan Kit

【FAQ】HarmonyOS SDK 闭源开放能力 —Scan Kit

1.问题描述

Scan Kit扫描专用底层码流接口需要鉴权,鉴权失败后功能还能用吗?

解决方案

如果已经申请过白名单,因为异常导致的鉴权失败会优先放通,保障业务成功。

2.问题描述

调用Scan Kit扫描专用底层码流接口会不会将二维码直接解出来?

解决方案

不会解析用户数据,Scan Kit接口只会检测二维码的位置,不会尝试去解码。

3.问题描述

自定义扫码界面的时候相机显示的画面变型,如何获取到一个合适的分辨率不变形?

解决方案

请参考文档:https://developer.huawei.com/consumer/cn/codelabsPortal/carddetails/tutorials_ScanKit-Codelab-Clientdemo-ArkTS。可通过监听组件onAreaChange方法获取手机屏幕宽高,您可以根据实际情况按百分比进行设计。
关键代码示例:

Column() {
XComponent({
id: 'componentId',
type: 'surface',
controller: this.mXComponentController
})
.onLoad(async () => {
hilog.info(0x0001, TAG, 'onLoad is called');
// 获取XComponent组件的surfaceId
this.surfaceId = this.mXComponentController.getXComponentSurfaceId();
hilog.info(0x0001, TAG, 'surfaceId: %{public}s', this.surfaceId)
let viewControl: customScan.ViewControl = {
width: this.cameraWidth,
height: this.cameraHeight,
surfaceId: this.surfaceId
};
// 扫码结果放置到回调中处理
try {
customScan.start(viewControl, this.callback);
this.isFlashLightEnable = true;
} catch (error) {
hilog.error(0x0001, TAG, 'start fail, error: %{public}s', JSON.stringify(error));
}
})
// XComponent宽、高、位置偏移量默认使用单位:vp
.width(this.cameraWidth)
.height(this.cameraHeight)
.position({ x: this.cameraOffsetX, y: this.cameraOffsetY })
}
.height('100%')
.width('100%')
.onAreaChange((oldValue: Area, newValue: Area) => {
// 获取当前组件宽高,newValue返回width、height值,单位vp,计算XComponent组件大小
hilog.info(0x0001, TAG, 'newValue : %{public}s, ', JSON.stringify(newValue));
this.calcArea(newValue.width as number, newValue.height as number);
})
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/444717
推荐阅读
相关标签
  

闽ICP备14008679号