HarmonyOS customScan.start扫码报错1000500001

在XComponent组件的onLoad回调中请求ohos.permission.CAMERA权限,权限请求成功后再去调用 customScan.start方法,报错1000500001,在已获取ohos.permission.CAMERA权限后重新打开页面调用customScan.start是正常的

HarmonyOS
2024-12-19 17:19:37
1099浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
put_get

几个要点:

1、module.json5中添加camera的权限声明。

2、拉起自定义扫码界面时需要动态申请相机的权限,等待用户授权。

3、用户授权后在启动相机流进行扫码。

4、获取扫码结果 附权限声明:

"requestPermissions": [
  {
    "name": "ohos.permission.CAMERA",
    "reason": "$string:reason",
    "usedScene": {
      "abilities": [
        "FormAbility"
      ],
      "when": "inuse"
    }
  }
]
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
分享
微博
QQ
微信
回复
2024-12-19 19:35:10


相关问题
HarmonyOS customScan.init报错1000500001
615浏览 • 1回复 待解决
HarmonyOS 直达问题
819浏览 • 1回复 待解决
HarmonyOS 需要demo
912浏览 • 1回复 待解决
相册识别多失败
2682浏览 • 1回复 待解决
HarmonyOS模块”通用能力
900浏览 • 1回复 待解决
HarmonyOS 服务权限问题
941浏览 • 1回复 待解决
HarmonyOS 是否有功能
781浏览 • 1回复 待解决
HarmonyOS 自定义咨询
648浏览 • 1回复 待解决
HarmonyOS APP可以生成二维安装
1590浏览 • 1回复 待解决