Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
90851d9b
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
90851d9b
编写于
10月 17, 2022
作者:
朱
朱天怡
提交者:
Gitee
10月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改
Signed-off-by:
N
朱天怡
<
zhutianyi2@huawei.com
>
上级
b166a489
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
103 addition
and
67 deletion
+103
-67
zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md
...ation-dev/reference/apis/js-apis-backgroundTaskManager.md
+12
-1
zh-cn/application-dev/reference/apis/js-apis-workScheduler.md
...n/application-dev/reference/apis/js-apis-workScheduler.md
+87
-62
zh-cn/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md
...n-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md
+2
-2
zh-cn/application-dev/reference/errorcodes/errorcode-workScheduler.md
...ation-dev/reference/errorcodes/errorcode-workScheduler.md
+2
-2
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md
浏览文件 @
90851d9b
...
...
@@ -13,6 +13,13 @@
> **说明:**
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
js
import
backgroundTaskManager
from
'
@ohos.backgroundTaskManager
'
;
```
## backgroundTaskManager.requestSuspendDelay
## 导入模块
...
...
@@ -21,7 +28,7 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager';
```
## backgroundTaskManager.requestSuspendDelay
## backgroundTaskManager.requestSuspendDelay
<sup>(deprecated)</sup>
requestSuspendDelay(reason: string, callback: Callback
<
void
>
): DelaySuspendInfo
...
...
@@ -29,6 +36,10 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen
延迟挂起时间一般情况下默认值为180000,低电量(依据系统低电量广播)时默认值为60000。
> **说明:** 从API version 9开始废弃,建议使用[backgroundTaskManager.requestSuspendDelay](#reminderagentmanagerpublishreminder9)
>
> 从 API version 7开始支持。
**系统能力:**
SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
**参数**
:
...
...
zh-cn/application-dev/reference/apis/js-apis-workScheduler.md
浏览文件 @
90851d9b
...
...
@@ -9,6 +9,7 @@
> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块接口仅可在Stage模型下使用。
> - 延迟任务调度约束见[延迟任务调度概述](../../task-management/work-scheduler-overview.md)。
> - 延迟任务调度错误码见[延迟任务错误码](../errorcodes/errorcode-workScheduler.md)。
## 导入模块
...
...
@@ -18,7 +19,7 @@ import workScheduler from '@ohos.workScheduler';
```
## workScheduler.startWork
startWork(work: WorkInfo):
boolean
startWork(work: WorkInfo):
void
通知WorkSchedulerService将工作添加到执行队列。
...
...
@@ -30,12 +31,6 @@ startWork(work: WorkInfo): boolean
| ---- | --------------------- | ---- | -------------- |
| work |
[
WorkInfo
](
#workinfo
)
| 是 | 指示要添加到执行队列的工作。 |
**返回值**
:
| 类型 | 说明 |
| ------- | -------------------------------- |
| boolean | 如果工作成功添加到执行队列,则返回true,否则返回false。 |
**示例**
:
```
js
...
...
@@ -53,12 +48,16 @@ startWork(work: WorkInfo): boolean
mykey3
:
1.5
}
}
var
res
=
workScheduler
.
startWork
(
workInfo
);
console
.
info
(
`workschedulerLog res:
${
res
}
`
);
try
{
workScheduler
.
startWork
(
workInfo
);
console
.
info
(
'
workschedulerLog startWork success
'
);
}
catch
(
error
)
{
console
.
error
(
`workschedulerLog startwork failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
```
## workScheduler.stopWork
stopWork(work: WorkInfo, needCancel?: boolean):
boolean
stopWork(work: WorkInfo, needCancel?: boolean):
void
通知WorkSchedulerService停止指定工作。
...
...
@@ -71,12 +70,6 @@ stopWork(work: WorkInfo, needCancel?: boolean): boolean
| work |
[
WorkInfo
](
#workinfo
)
| 是 | 指示要停止的工作。 |
| needCancel | boolean | 是 | 是否需要取消的工作。 |
**返回值**
:
| 类型 | 说明 |
| ------- | ----------------------- |
| boolean | 如果成功,则返回true,否则返回false。 |
**示例**
:
```
js
...
...
@@ -94,8 +87,12 @@ stopWork(work: WorkInfo, needCancel?: boolean): boolean
mykey3
:
1.5
}
}
var
res
=
workScheduler
.
stopWork
(
workInfo
,
false
);
console
.
info
(
`workschedulerLog res:
${
res
}
`
);
try
{
workScheduler
.
stopWork
(
workInfo
,
false
);
console
.
info
(
'
workschedulerLog stopWork success
'
);
}
catch
(
error
)
{
console
.
error
(
`workschedulerLog stopWork failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
```
## workScheduler.getWorkStatus
...
...
@@ -115,15 +112,19 @@ getWorkStatus(workId: number, callback : AsyncCallback\<WorkInfo>): void
**示例**
:
```
js
workScheduler
.
getWorkStatus
(
50
,
(
err
,
res
)
=>
{
if
(
err
)
{
console
.
info
(
`workschedulerLog getWorkStatus failed, because:
${
err
.
code
}
`
);
}
else
{
for
(
let
item
in
res
)
{
console
.
info
(
`workschedulerLog getWorkStatus success,
${
item
}
is:
${
res
[
item
]}
`
);
try
{
workScheduler
.
getWorkStatus
(
50
,
(
error
,
res
)
=>
{
if
(
error
)
{
console
.
error
(
`workschedulerLog getWorkStatus failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
else
{
for
(
let
item
in
res
)
{
console
.
info
(
`workschedulerLog getWorkStatus success,
${
item
}
is:
${
res
[
item
]}
`
);
}
}
}
});
});
}
catch
(
error
)
{
console
.
error
(
`workschedulerLog getWorkStatus failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
```
## workScheduler.getWorkStatus
...
...
@@ -148,13 +149,17 @@ getWorkStatus(workId: number): Promise\<WorkInfo>
**示例**
:
```
js
workScheduler
.
getWorkStatus
(
50
).
then
((
res
)
=>
{
for
(
let
item
in
res
)
{
console
.
info
(
`workschedulerLog getWorkStatus success,
${
item
}
is:
${
res
[
item
]}
`
);
}
}).
catch
((
err
)
=>
{
console
.
info
(
`workschedulerLog getWorkStatus failed, because:
${
err
.
code
}
`
);
})
try
{
workScheduler
.
getWorkStatus
(
50
).
then
((
res
)
=>
{
for
(
let
item
in
res
)
{
console
.
info
(
`workschedulerLog getWorkStatus success,
${
item
}
is:
${
res
[
item
]}
`
);
}
}).
catch
((
error
)
=>
{
console
.
error
(
`workschedulerLog getWorkStatus failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
})
}
catch
(
error
)
{
console
.
error
(
`workschedulerLog getWorkStatus failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
```
## workScheduler.obtainAllWorks
...
...
@@ -179,13 +184,17 @@ obtainAllWorks(callback : AsyncCallback\<void>): Array\<WorkInfo>
**示例**
:
```
js
workScheduler
.
obtainAllWorks
((
err
,
res
)
=>
{
if
(
err
)
{
console
.
info
(
`workschedulerLog obtainAllWorks failed, because:
${
err
.
code
}
`
);
}
else
{
console
.
info
(
`workschedulerLog obtainAllWorks success, data is:
${
JSON
.
stringify
(
res
)}
`
);
}
});
try
{
workScheduler
.
obtainAllWorks
((
error
,
res
)
=>
{
if
(
error
)
{
console
.
error
(
`workschedulerLog obtainAllWorks failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
else
{
console
.
info
(
`workschedulerLog obtainAllWorks success, data is:
${
JSON
.
stringify
(
res
)}
`
);
}
});
}
catch
(
error
)
{
console
.
error
(
`workschedulerLog obtainAllWorks failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
```
## workScheduler.obtainAllWorks
...
...
@@ -204,15 +213,19 @@ obtainAllWorks(): Promise<Array\<WorkInfo>>
**示例**
:
```
js
workScheduler
.
obtainAllWorks
().
then
((
res
)
=>
{
console
.
info
(
`workschedulerLog obtainAllWorks success, data is:
${
JSON
.
stringify
(
res
)}
`
);
}).
catch
((
err
)
=>
{
console
.
info
(
`workschedulerLog obtainAllWorks failed, because:
${
err
.
code
}
`
);
})
try
{
workScheduler
.
obtainAllWorks
().
then
((
res
)
=>
{
console
.
info
(
`workschedulerLog obtainAllWorks success, data is:
${
JSON
.
stringify
(
res
)}
`
);
}).
catch
((
error
)
=>
{
console
.
error
(
`workschedulerLog obtainAllWorks failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
})
}
catch
(
error
)
{
console
.
error
(
`workschedulerLog obtainAllWorks failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
```
## workScheduler.stopAndClearWorks
stopAndClearWorks():
boolean
stopAndClearWorks():
void
停止和取消与当前应用程序关联的所有工作。
...
...
@@ -221,8 +234,12 @@ stopAndClearWorks(): boolean
**示例**
:
```
js
let
res
=
workScheduler
.
stopAndClearWorks
();
console
.
info
(
`workschedulerLog res:
${
res
}
`
);
try
{
workScheduler
.
stopAndClearWorks
();
console
.
info
(
`workschedulerLog stopAndClearWorks success`
);
}
catch
(
error
)
{
console
.
error
(
`workschedulerLog stopAndClearWorks failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
```
## workScheduler.isLastWorkTimeOut
...
...
@@ -248,13 +265,17 @@ isLastWorkTimeOut(workId: number, callback : AsyncCallback\<void>): boolean
**示例**
:
```
js
workScheduler
.
isLastWorkTimeOut
(
500
,
(
err
,
res
)
=>
{
if
(
err
)
{
console
.
info
(
`workschedulerLog isLastWorkTimeOut failed, because:
${
err
.
code
}
`
);
}
else
{
console
.
info
(
`workschedulerLog isLastWorkTimeOut success, data is:
${
res
}
`
);
}
});
try
{
workScheduler
.
isLastWorkTimeOut
(
500
,
(
error
,
res
)
=>
{
if
(
error
)
{
onsole
.
error
(
`workschedulerLog isLastWorkTimeOut failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
else
{
console
.
info
(
`workschedulerLog isLastWorkTimeOut success, data is:
${
res
}
`
);
}
});
}
catch
(
error
)
{
console
.
error
(
`workschedulerLog isLastWorkTimeOut failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
```
## workScheduler.isLastWorkTimeOut
...
...
@@ -279,13 +300,17 @@ isLastWorkTimeOut(workId: number): Promise\<boolean>
**示例**
:
```
js
workScheduler
.
isLastWorkTimeOut
(
500
)
.
then
(
res
=>
{
console
.
info
(
`workschedulerLog isLastWorkTimeOut success, data is:
${
res
}
`
);
})
.
catch
(
err
=>
{
console
.
info
(
`workschedulerLog isLastWorkTimeOut failed, because:
${
err
.
code
}
`
);
});
try
{
workScheduler
.
isLastWorkTimeOut
(
500
)
.
then
(
res
=>
{
console
.
info
(
`workschedulerLog isLastWorkTimeOut success, data is:
${
res
}
`
);
})
.
catch
(
error
=>
{
console
.
error
(
`workschedulerLog isLastWorkTimeOut failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
});
}
catch
(
error
)
{
console
.
error
(
`workschedulerLog isLastWorkTimeOut failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
```
## WorkInfo
...
...
zh-cn/application-dev/reference/errorcodes/errorcode-backgroundTaskMgr.md
浏览文件 @
90851d9b
...
...
@@ -40,7 +40,7 @@ Memory operation failed.
## 9800002 Parcel读写操作失败
### 错误信息
The number of reminders exceeds the limit
.
Parcel operation failed
.
### 可能原因
1.
调用MessageParcel对象读取或写入对象异常
...
...
@@ -62,7 +62,7 @@ Inner transact failed.
## 9800004 系统服务失败
### 错误信息
Inner transact
failed.
System service operation
failed.
### 可能原因
1.
系统服务还未启动
...
...
zh-cn/application-dev/reference/errorcodes/errorcode-workScheduler.md
浏览文件 @
90851d9b
...
...
@@ -29,7 +29,7 @@ Memory operation failed.
## 9700002 Parcel读写操作失败
### 错误信息
The number of reminders exceeds the limit
.
Parcel operation failed
.
### 可能原因
1.
调用MessageParcel对象读取或写入对象异常
...
...
@@ -40,7 +40,7 @@ The number of reminders exceeds the limit.
## 9700003 系统服务失败
### 错误信息
Inner transact
failed.
System service operation
failed.
### 可能原因
1.
系统服务还未启动
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录