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

!3321 描述修改

Merge pull request !3321 from wuang/master
......@@ -42,7 +42,8 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager';
console.info("Request suspension delay will time out.");
});
var id = delayInfo.requestId;console.info("requestId is: " + id);
var id = delayInfo.requestId;
console.info("requestId is: " + id);
```
......@@ -50,9 +51,9 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager';
```js
backgroundTaskManager.getRemainingDelayTime(id).then( res => {
console.log('promise => Operation succeeded. Data: ' + JSON.stringify(res));
console.log('promise => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res));
}).catch( err => {
console.log('promise => Operation failed. Cause: ' + err.data);
console.log('promise => Operation getRemainingDelayTime failed. Cause: ' + err.data);
});
```
......@@ -83,9 +84,9 @@ console.info("The actualDelayTime is: " + time);
// 获取应用程序进入挂起状态前的剩余时间
backgroundTaskManager.getRemainingDelayTime(id).then( res => {
console.log('promise => Operation succeeded. Data: ' + JSON.stringify(res));
console.log('promise => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res));
}).catch( err => {
console.log('promise => Operation failed. Cause: ' + err.data);
console.log('promise => Operation getRemainingDelayTime failed. Cause: ' + err.data);
});
// 取消延迟挂起
......@@ -172,16 +173,16 @@ ohos.permission.KEEP_BACKGROUND_RUNNING
],
operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG]
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
// 通过wantAgent模块的getWantAgent方法获取WantAgent对象
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => {
console.info("Operation succeeded");
console.info("Operation startBackgroundRunning succeeded");
}).catch((err) => {
console.error("Operation failed Cause: " + err);
console.error("Operation startBackgroundRunning failed Cause: " + err);
});
});
```
......@@ -193,9 +194,9 @@ ohos.permission.KEEP_BACKGROUND_RUNNING
import featureAbility from '@ohos.ability.featureAbility';
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => {
console.info("Operation succeeded");
console.info("Operation stopBackgroundRunning succeeded");
}).catch((err) => {
console.error("Operation failed Cause: " + err);
console.error("Operation stopBackgroundRunning failed Cause: " + err);
});
```
......@@ -220,25 +221,25 @@ function startBackgroundRunning() {
],
operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG]
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
// 通过wantAgent模块的getWantAgent方法获取WantAgent对象
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => {
console.info("Operation succeeded");
console.info("Operation startBackgroundRunning succeeded");
}).catch((err) => {
console.error("Operation failed Cause: " + err);
console.error("Operation startBackgroundRunning failed Cause: " + err);
});
});
}
function stopBackgroundRunning() {
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => {
console.info("Operation succeeded");
console.info("Operation stopBackgroundRunning succeeded");
}).catch((err) => {
console.error("Operation failed Cause: " + err);
console.error("Operation stopBackgroundRunning failed Cause: " + err);
});
}
......
......@@ -33,11 +33,17 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen
| [DelaySuspendInfo](#delaysuspendinfo) | 返回延迟挂起信息。 |
**示例**
```js
let myReason = 'test requestSuspendDelay';
let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
console.info("Request suspension delay will time out.");
})
var id = delayInfo.requestId;
var time = delayInfo.actualDelayTime;
console.info("The requestId is: " + id);
console.info("The actualDelayTime is: " + time);
```
......@@ -61,9 +67,9 @@ getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>):
let id = 1;
backgroundTaskManager.getRemainingDelayTime(id, (err, res) => {
if(err.data === 0) {
console.log('promise => Operation succeeded. Data: ' + JSON.stringify(res));
console.log('callback => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res));
} else {
console.log('promise => Operation failed. Cause: ' + err.data);
console.log('callback => Operation getRemainingDelayTime failed. Cause: ' + err.data);
}
})
```
......@@ -91,9 +97,9 @@ getRemainingDelayTime(requestId: number): Promise<number>
```js
let id = 1;
backgroundTaskManager.getRemainingDelayTime(id).then( res => {
console.log('promise => Operation succeeded. Data: ' + JSON.stringify(res));
console.log('promise => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res));
}).catch( err => {
console.log('promise => Operation failed. Cause: ' + err.data);
console.log('promise => Operation getRemainingDelayTime failed. Cause: ' + err.data);
})
```
......@@ -143,9 +149,9 @@ import wantAgent from '@ohos.wantAgent';
function callback(err, data) {
if (err) {
console.error("Operation failed Cause: " + err);
console.error("Operation startBackgroundRunning failed Cause: " + err);
} else {
console.info("Operation succeeded");
console.info("Operation startBackgroundRunning succeeded");
}
}
......@@ -158,7 +164,7 @@ let wantAgentInfo = {
],
operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG]
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
......@@ -206,15 +212,15 @@ let wantAgentInfo = {
],
operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG]
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => {
console.info("Operation succeeded");
console.info("Operation startBackgroundRunning succeeded");
}).catch((err) => {
console.error("Operation failed Cause: " + err);
console.error("Operation startBackgroundRunning failed Cause: " + err);
});
});
......@@ -241,9 +247,9 @@ import featureAbility from '@ohos.ability.featureAbility';
function callback(err, data) {
if (err) {
console.error("Operation failed Cause: " + err);
console.error("Operation stopBackgroundRunning failed Cause: " + err);
} else {
console.info("Operation succeeded");
console.info("Operation stopBackgroundRunning succeeded");
}
}
......@@ -275,9 +281,9 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager';
import featureAbility from '@ohos.ability.featureAbility';
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => {
console.info("Operation succeeded");
console.info("Operation stopBackgroundRunning succeeded");
}).catch((err) => {
console.error("Operation failed Cause: " + err);
console.error("Operation stopBackgroundRunning failed Cause: " + err);
});
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册