HarmonyOS 鸿蒙Next打开手电筒模式失败,The setTorchMode call failed. error code: 7400102
HarmonyOS 鸿蒙Next打开手电筒模式失败,The setTorchMode call failed. error code: 7400102
我参考文档给出的代码,希望打开手电筒模式之后报错:The setTorchMode call failed. error code: 7400102
function setTorchMode(cameraManager: camera.CameraManager, torchMode: camera.TorchMode): void {
try {
cameraManager.setTorchMode(torchMode);
} catch (error) {
// 失败返回错误码error.code并处理
let err = error as BusinessError;
console.error(The setTorchMode call failed. error code: ${err.code}
);
}
}
不知道哪位老师知道该怎么解决
2 回复
可能是执行顺序问题,请检查下执行顺序,cameramanage是否创建,或者配置是否成功提交
可以参考如下资料
拍照实现方案(ArkTS)-相机最佳实践(ArkTS)-Camera Kit(相机服务)-媒体 - 华为HarmonyOS开发者 (huawei.com),参考流程图的流程进行操作