提交 5bafcc8e 编写于 作者: Z zhangxin_T

bugfix

Signed-off-by: Nzhangxin_T <zhangxin312@huawei.com>
上级 31c942ee
...@@ -265,7 +265,7 @@ import featureAbility from '@ohos.ability.featureAbility'; ...@@ -265,7 +265,7 @@ import featureAbility from '@ohos.ability.featureAbility';
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.wantAgent';
import rpc from "@ohos.rpc"; import rpc from "@ohos.rpc";
function startBackgroundRunning() { function startContinuousTask() {
let wantAgentInfo = { let wantAgentInfo = {
// 点击通知后,将要执行的动作列表 // 点击通知后,将要执行的动作列表
wants: [ wants: [
...@@ -293,7 +293,7 @@ function startBackgroundRunning() { ...@@ -293,7 +293,7 @@ function startBackgroundRunning() {
}); });
} }
function stopBackgroundRunning() { function stopContinuousTask() {
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => { backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => {
console.info("Operation stopBackgroundRunning succeeded"); console.info("Operation stopBackgroundRunning succeeded");
}).catch((err) => { }).catch((err) => {
...@@ -302,10 +302,10 @@ function stopBackgroundRunning() { ...@@ -302,10 +302,10 @@ function stopBackgroundRunning() {
} }
async function processAsyncJobs() { async function processAsyncJobs() {
// 此处添加执行具体长时任务的代码 // 此处执行具体的长时任务
// 长时任务执行完,调用取消接口,释放资源。 // 长时任务执行完,调用取消接口,释放资源。
stopBackgroundRunning(); stopContinuousTask();
} }
let mMyStub; let mMyStub;
...@@ -323,11 +323,11 @@ class MyStub extends rpc.RemoteObject { ...@@ -323,11 +323,11 @@ class MyStub extends rpc.RemoteObject {
// code 的具体含义用户自定义 // code 的具体含义用户自定义
if (code === 1) { if (code === 1) {
// 接收到申请长时任务的请求码 // 接收到申请长时任务的请求码
startBackgroundRunning(); startContinuousTask();
// 此处执行具体长时任务 // 此处执行具体长时任务
} else if (code === 2) { } else if (code === 2) {
// 接收到取消长时任务的请求码 // 接收到取消长时任务的请求码
stopBackgroundRunning(); stopContinuousTask();
} else { } else {
console.log('ServiceAbility unknown request code'); console.log('ServiceAbility unknown request code');
} }
...@@ -340,7 +340,7 @@ export default { ...@@ -340,7 +340,7 @@ export default {
console.info('ServiceAbility onStart'); console.info('ServiceAbility onStart');
mMyStub = new MyStub("ServiceAbility-test"); mMyStub = new MyStub("ServiceAbility-test");
// 在执行后台长时任前,调用申请接口。 // 在执行后台长时任前,调用申请接口。
startBackgroundRunning(); startContinuousTask();
processAsyncJobs(); processAsyncJobs();
}, },
onStop() { onStop() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册