百度Harmony Next 定位SDK提供后台持续定位的能力,可在应用退至后台的状态下,持续记录位置信息。具体使用方法如下:
let wantAgentInfo: wantAgent.WantAgentInfo = {wants: [{bundleName: "bundleName",abilityName: "abilityName"}],operationType: wantAgent.OperationType.START_ABILITY,requestCode: 0,wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]};wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj: WantAgent) => {if (locClient != null) {locClient.enableLocInBackground(wantAgentObj);}});
if (this.client != null) {this.client.disableLocInBackground();}
“abilities”: [..."backgroundModes": [// 长时任务类型的配置项"location"]]并申请长时任务权限
上一篇
下一篇
本篇文章对您是否有帮助?