From 023f07339094652a27d9b40db2af1e19a78f34ae Mon Sep 17 00:00:00 2001 From: wangqing Date: Wed, 23 Mar 2022 19:50:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangqing --- .../background-task-dev-guide.md | 53 ++++++++++++------- .../reference/apis/js-apis-particleAbility.md | 10 ++-- 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/zh-cn/application-dev/background-task-management/background-task-dev-guide.md b/zh-cn/application-dev/background-task-management/background-task-dev-guide.md index 873a675496..6fb964b195 100644 --- a/zh-cn/application-dev/background-task-management/background-task-dev-guide.md +++ b/zh-cn/application-dev/background-task-management/background-task-dev-guide.md @@ -110,17 +110,17 @@ ohos.permission.KEEP_BACKGROUND_RUNNING **表4** 后台模式类型 -| 参数名 | id值 | 描述 | -| -------- | -------- | -------- | -| DATA_TRANSFER | 1 | 数据传输 | -| AUDIO_PLAYBACK | 2 | 音频播放 | -| AUDIO_RECORDING | 3 | 录音 | -| LOCATION | 4 | 定位导航 | -| BLUETOOTH_INTERACTION | 5 | 蓝牙相关 | -| MULTI_DEVICE_CONNECTION | 6 | 多设备互联 | -| WIFI_INTERACTION | 7 | WLAN相关(系统保留) | -| VOIP | 8 | 音视频通话(系统保留) | -| TASK_KEEPING | 9 | 计算任务(仅供PC使用) | +| 参数名 | id值 | 描述 | 配置项 | +| -------- | -------- | -------- | -------- | +| DATA_TRANSFER | 1 | 数据传输 | dataTransfer | +| AUDIO_PLAYBACK | 2 | 音频播放 | audioPlayback | +| AUDIO_RECORDING | 3 | 录音 | audioRecording | +| LOCATION | 4 | 定位导航 | location | +| BLUETOOTH_INTERACTION | 5 | 蓝牙相关 | bluetoothInteraction | +| MULTI_DEVICE_CONNECTION | 6 | 多设备互联 | multiDeviceConnection | +| WIFI_INTERACTION | 7 | WLAN相关(系统保留) | wifiInteraction | +| VOIP | 8 | 音视频通话(系统保留) | voip | +| TASK_KEEPING | 9 | 计算任务(仅供PC使用) | taskKeeping | ## 开发步骤 @@ -129,13 +129,30 @@ ohos.permission.KEEP_BACKGROUND_RUNNING ```json "module": { - "package": "com.example.myapplication", - ..., - "reqPermissions": [ - { - "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" - } - ] + "package": "com.example.myapplication", + ... + "abilities": [ + ... + { + "backgroundModes": [ + "dataTransfer", + "location", + ... + ], + ... + "type": "service" + } + ], + "defPermissions": [ + { + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING" + } + ] } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md index 711b207e4c..0f7085bf8e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @@ -188,7 +188,7 @@ particleAbility.acquireDataAbilityHelper(uri) startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback<void>): void; -向系统申请长时任务,使用callback形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的api8接口) +向系统申请长时任务,使用callback形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的[api8接口](js-apis-backgroundTaskManager.md)) **系统能力**:SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask @@ -252,7 +252,7 @@ startBackgroundRunning(id: number, request: NotificationRequest): Promise<voi **系统能力**:SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -向系统申请长时任务,使用promise形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的api8接口) +向系统申请长时任务,使用promise形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的[api8接口](js-apis-backgroundTaskManager.md)) **参数:** @@ -313,7 +313,7 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { cancelBackgroundRunning(callback: AsyncCallback<void>): void; -向系统申请取消长时任务,使用callback形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的api8接口) +向系统申请取消长时任务,使用callback形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的[api8接口](js-apis-backgroundTaskManager.md)) **系统能力**:SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask @@ -344,7 +344,7 @@ particleAbility.cancelBackgroundRunning(callback); cancelBackgroundRunning(): Promise<void>; -向系统申请取消长时任务,使用promise形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的api8接口) +向系统申请取消长时任务,使用promise形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的[api8接口](js-apis-backgroundTaskManager.md)) **系统能力**:SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask @@ -516,7 +516,7 @@ function onConnectCallback(element, remote){ - + -- GitLab