ITPub博客

首页 > 移动开发 > ANDROID > 【FAQ】HarmonyOS SDK 闭源开放能力 —Scan Kit

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

原创 ANDROID 作者:HarmonyOS SDK 时间:2024-03-27 16:57:33 0 删除 编辑


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);
})


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70003787/viewspace-3010651/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
HarmonyOS SDK技术团队。分享最新的技术干货,带来最全的能力应用场景,更新热门开发者圈子活动。与开发者一起,同成长,共精彩。

注册时间:2021-07-15

  • 博文量
    627
  • 访问量
    729545