提交 686f9dee 编写于 作者: Z zhangxin_T

docs modify

Signed-off-by: Nzhangxin_T <zhangxin312@huawei.com>
上级 a598e044
......@@ -195,7 +195,7 @@ import featureAbility from '@ohos.ability.featureAbility';
import wantAgent from '@ohos.wantAgent';
import rpc from "@ohos.rpc";
function startBackgroundRunning() {
function startContinuousTask() {
let wantAgentInfo = {
// 点击通知后,将要执行的动作列表
wants: [
......@@ -223,7 +223,7 @@ function startBackgroundRunning() {
});
}
function stopBackgroundRunning() {
function stopContinuousTask() {
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => {
console.info("Operation stopBackgroundRunning succeeded");
}).catch((err) => {
......@@ -231,6 +231,13 @@ function stopBackgroundRunning() {
});
}
async function processAsyncJobs() {
// 此处执行具体的长时任务。
// 长时任务执行完,调用取消接口,释放资源。
stopContinuousTask();
}
let mMyStub;
class MyStub extends rpc.RemoteObject {
......@@ -262,9 +269,9 @@ export default {
onStart(want) {
console.info('ServiceAbility onStart');
mMyStub = new MyStub("ServiceAbility-test");
startBackgroundRunning();
// 此处执行后台具体的长时任务。
stopBackgroundRunning();
// 在执行后台长时任前,调用申请接口。
startContinuousTask();
processAsyncJobs();
},
onStop() {
console.info('ServiceAbility onStop');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册