未验证 提交 159299f7 编写于 作者: O openharmony_ci 提交者: Gitee

!13792 长时任务开发者指南示例代码vod问题处理

Merge pull request !13792 from 张鑫/master
...@@ -178,7 +178,7 @@ function startContinuousTask() { ...@@ -178,7 +178,7 @@ function startContinuousTask() {
// 通过wantAgent模块的getWantAgent方法获取WantAgent对象 // 通过wantAgent模块的getWantAgent方法获取WantAgent对象
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
try { try {
backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(), backgroundTaskManager.startBackgroundRunning(mContext,
backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => { backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => {
console.info("Operation startBackgroundRunning succeeded"); console.info("Operation startBackgroundRunning succeeded");
}).catch((error) => { }).catch((error) => {
...@@ -192,9 +192,9 @@ function startContinuousTask() { ...@@ -192,9 +192,9 @@ function startContinuousTask() {
function stopContinuousTask() { function stopContinuousTask() {
try { try {
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => { backgroundTaskManager.stopBackgroundRunning(mContext).then(() => {
console.info("Operation stopBackgroundRunning succeeded"); console.info("Operation stopBackgroundRunning succeeded");
}).catch((err) => { }).catch((error) => {
console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`); console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
}); });
} catch (error) { } catch (error) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册