Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LocationActivityService

en

class for location action

zh

处理活动识别相关的类

Hierarchy

  • HMSBaseService
    • LocationActivityService

Index

Constructors

constructor

Properties

Static StatusCode

StatusCode: LocationStatusCode = LocationStatusCode

Methods

createActivityConversionUpdates

  • createActivityConversionUpdates(infoList: Array<ConversionInfo>): void
  • en

    create activity conversion updates

    zh

    提供检测活动转换条件(进入、退出)的功能,例如需要检测用户从走路变为骑自行车的状态等

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

    Parameters

    Returns void

createActivityIdentificationUpdates

  • createActivityIdentificationUpdates(interval: number): void
  • en

    create activity identification updates

    zh

    注册活动识别更新

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

    Parameters

    Returns void

deleteActivityConversionUpdates

  • deleteActivityConversionUpdates(): void
  • en

    delete activity conversion updates

    zh

    移除当前的关联活动转换更新

    example
    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();
    

    Returns void

deleteActivityIdentificationUpdates

  • deleteActivityIdentificationUpdates(): void
  • en

    delete activity identification updates

    zh

    移除活动识别更新

    example
    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();
    

    Returns void

off

  • off(event_name: string, callback: Function, target: any): void
  • en

    remove event listener

    zh

    取消事件的监听

    example
    huawei.hms.location.locationActivityService.off(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_ACTIVITY_UPDATES, (result) => {
        //TODO
    }
    

    Parameters

    • event_name: string

      event name

    • callback: Function

      callback function

    • target: any

      target node

    Returns void

on

  • on(event_name: string, cb: Function, node?: any): void
  • en

    event listener

    zh

    持续监听事件

    example
    huawei.hms.location.locationActivityService.on(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_ACTIVITY_UPDATES, (result) => {
        //TODO
    }
    

    Parameters

    • event_name: string

      event name

    • cb: Function

      event callback

    • Optional node: any

      target node

    Returns void

once

  • once(event_name: string, cb: Function, node?: any): void
  • en

    event listener for once

    zh

    监听一次事件

    example
    huawei.hms.location.locationActivityService.once(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_DELETE_ACTIVITY_IDENTIFICATION_UPDATES, (result) => {
        //TODO
    }
    

    Parameters

    • event_name: string

      event name

    • cb: Function

      event callback

    • Optional node: any

      target node

    Returns void

requestRecognitionPermission

  • requestRecognitionPermission(): void
  • en

    request recognition permission

    zh

    请求活动相关的权限

    example
    huawei.hms.location.locationActivityService.requestRecognitionPermission();
    

    Returns void

targetOff

  • targetOff(target_node: any): void
  • en

    remove all event listener for the node

    zh

    取消某个节点所有的事件监听

    example
    huawei.hms.location.locationService.targetOff(this);
    

    Parameters

    • target_node: any

    Returns void

Generated using TypeDoc