目录
1.背景
2.解决方案
1.背景
使用OpenHarmony 5.0调用光感接口崩溃,返回的值是undefined,接口如下:
sensor.on(sensor.SensorId.AMBIENT_LIGHT, (data) => {if (data == null || data == undefined || data.intensity == null || data.intensity == undefined) {return}Logger.info(TAG, 'The ambient light intensity: ' + data.intensity)this.tip = getContext(this).resourceManager.getStringSync($r('app.string.light_sensor_level')).toString() + data.intensityif (this.intensity != 0 && this.intens