class for location action
处理活动识别相关的类
create activity conversion updates
提供检测活动转换条件(进入、退出)的功能,例如需要检测用户从走路变为骑自行车的状态等
huawei.hms.location.locationActivityService.once(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_CREATE_ACTIVITY_CONVERSION_UPDATES, (result) => { if (result.code === huawei.hms.location.LocationActivityService.StatusCode.success) { cc.log('createActivityConversionUpdates...', 'success'); } else { cc.log('createActivityConversionUpdates...', 'fail:', result.errMsg); } }); let cls = huawei.hms.location.ConversionInfo; let type = huawei.hms.location.ACTIVITY_IDENTIFICATION_ENUM; let cType = huawei.hms.location.ACTIVITY_CONVERSION_TYPE; let infoList = [ new cls(type.STILL, cType.ENTER_ACTIVITY_CONVERSION), new cls(type.STILL, cType.EXIT_ACTIVITY_CONVERSION), ]; huawei.hms.location.locationActivityService.createActivityConversionUpdates(infoList);
create activity identification updates
注册活动识别更新
huawei.hms.location.locationActivityService.once(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_CREATE_ACTIVITY_IDENTIFICATION_UPDATES, (result) => { if (result.code === huawei.hms.location.LocationActivityService.StatusCode.success) { cc.log('requestActivityUpdates...', 'success'); } else { cc.log('requestActivityUpdates...', 'fail:', result.errMsg); } }); huawei.hms.location.locationActivityService.createActivityIdentificationUpdates(parseInt(time) || 5000);
(https://developer.huawei.com/consumer/en/doc/HMSCore-References-V5/activityidentificationservice-0000001050986183-V5)
delete activity conversion updates
移除当前的关联活动转换更新
huawei.hms.location.locationActivityService.once(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_REMOVE_ACTIVITY_CONVERSION_UPDATES, (result) => { if (result.code === huawei.hms.location.LocationActivityService.StatusCode.success) { cc.log('deleteActivityConversionUpdates...', 'success'); } else { cc.log('deleteActivityConversionUpdates...', 'fail:', result.errMsg); } }); huawei.hms.location.locationActivityService.deleteActivityConversionUpdates();
delete activity identification updates
移除活动识别更新
huawei.hms.location.locationActivityService.once(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_REMOVE_ACTIVITY_CONVERSION_UPDATES, (result) => { if (result.code === huawei.hms.location.LocationActivityService.StatusCode.success) { cc.log('deleteActivityUpdates...', 'success'); } else { cc.log('deleteActivityUpdates...', 'fail:', result.errMsg); } }); huawei.hms.location.locationActivityService.deleteActivityIdentificationUpdates();
remove event listener
取消事件的监听
huawei.hms.location.locationActivityService.off(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_ACTIVITY_UPDATES, (result) => { //TODO }
event name
callback function
target node
event listener
持续监听事件
huawei.hms.location.locationActivityService.on(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_ACTIVITY_UPDATES, (result) => { //TODO }
event callback
event listener for once
监听一次事件
huawei.hms.location.locationActivityService.once(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_DELETE_ACTIVITY_IDENTIFICATION_UPDATES, (result) => { //TODO }
request recognition permission
请求活动相关的权限
huawei.hms.location.locationActivityService.requestRecognitionPermission();
remove all event listener for the node
取消某个节点所有的事件监听
huawei.hms.location.locationService.targetOff(this);
Generated using TypeDoc
class for location action
处理活动识别相关的类