Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
51634731
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
未验证
提交
51634731
编写于
1月 30, 2023
作者:
朱
朱天怡
提交者:
Gitee
1月 30, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改导入模块
Signed-off-by:
N
朱天怡
<
zhutianyi2@huawei.com
>
上级
20ee238b
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
51 addition
and
43 deletion
+51
-43
zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md
...ation-dev/reference/apis/js-apis-backgroundTaskManager.md
+12
-12
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md
...ce/apis/js-apis-resourceschedule-backgroundTaskManager.md
+39
-31
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md
浏览文件 @
51634731
...
@@ -205,9 +205,9 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
...
@@ -205,9 +205,9 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
Stage模型示例:
Stage模型示例:
```
ts
```
ts
import
Ability
from
'
@ohos.application.
Ability
'
;
import
UIAbility
from
'
@ohos.app.ability.UI
Ability
'
;
import
backgroundTaskManager
from
'
@ohos.backgroundTaskManager
'
;
import
backgroundTaskManager
from
'
@ohos.backgroundTaskManager
'
;
import
wantAgent
from
'
@ohos.wantAgent
'
;
import
wantAgent
from
'
@ohos.
app.ability.
wantAgent
'
;
function
callback
(
err
,
data
)
{
function
callback
(
err
,
data
)
{
if
(
err
)
{
if
(
err
)
{
...
@@ -217,13 +217,13 @@ function callback(err, data) {
...
@@ -217,13 +217,13 @@ function callback(err, data) {
}
}
}
}
export
default
class
MainAbility
extends
Ability
{
export
default
class
EntryAbility
extends
UI
Ability
{
onCreate
(
want
,
launchParam
)
{
onCreate
(
want
,
launchParam
)
{
let
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
bundleName
:
"
com.example.myapplication
"
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
com.example.myapplication.Main
Ability
"
abilityName
:
"
Entry
Ability
"
}
}
],
],
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
...
@@ -297,17 +297,17 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
...
@@ -297,17 +297,17 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
Stage模型示例:
Stage模型示例:
```
ts
```
ts
import
Ability
from
'
@ohos.application.
Ability
'
;
import
UIAbility
from
'
@ohos.app.ability.UI
Ability
'
;
import
backgroundTaskManager
from
'
@ohos.backgroundTaskManager
'
;
import
backgroundTaskManager
from
'
@ohos.backgroundTaskManager
'
;
import
wantAgent
from
'
@ohos.wantAgent
'
;
import
wantAgent
from
'
@ohos.
app.ability.
wantAgent
'
;
export
default
class
MainAbility
extends
Ability
{
export
default
class
EntryAbility
extends
UI
Ability
{
onCreate
(
want
,
launchParam
)
{
onCreate
(
want
,
launchParam
)
{
let
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
bundleName
:
"
com.example.myapplication
"
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
com.example.myapplication.Main
Ability
"
abilityName
:
"
Entry
Ability
"
}
}
],
],
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
...
@@ -365,7 +365,7 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext(), callbac
...
@@ -365,7 +365,7 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext(), callbac
Stage模型示例:
Stage模型示例:
```
ts
```
ts
import
Ability
from
'
@ohos.application.
Ability
'
;
import
UIAbility
from
'
@ohos.app.ability.UI
Ability
'
;
import
backgroundTaskManager
from
'
@ohos.backgroundTaskManager
'
;
import
backgroundTaskManager
from
'
@ohos.backgroundTaskManager
'
;
function
callback
(
err
,
data
)
{
function
callback
(
err
,
data
)
{
...
@@ -376,7 +376,7 @@ function callback(err, data) {
...
@@ -376,7 +376,7 @@ function callback(err, data) {
}
}
}
}
export
default
class
MainAbility
extends
Ability
{
export
default
class
EntryAbility
extends
UI
Ability
{
onCreate
(
want
,
launchParam
)
{
onCreate
(
want
,
launchParam
)
{
backgroundTaskManager
.
stopBackgroundRunning
(
this
.
context
,
callback
);
backgroundTaskManager
.
stopBackgroundRunning
(
this
.
context
,
callback
);
}
}
...
@@ -422,10 +422,10 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(()
...
@@ -422,10 +422,10 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(()
Stage模型示例:
Stage模型示例:
```
ts
```
ts
import
Ability
from
'
@ohos.application.
Ability
'
;
import
UIAbility
from
'
@ohos.app.ability.UI
Ability
'
;
import
backgroundTaskManager
from
'
@ohos.backgroundTaskManager
'
;
import
backgroundTaskManager
from
'
@ohos.backgroundTaskManager
'
;
export
default
class
MainAbility
extends
Ability
{
export
default
class
EntryAbility
extends
UI
Ability
{
onCreate
(
want
,
launchParam
)
{
onCreate
(
want
,
launchParam
)
{
backgroundTaskManager
.
stopBackgroundRunning
(
this
.
context
).
then
(()
=>
{
backgroundTaskManager
.
stopBackgroundRunning
(
this
.
context
).
then
(()
=>
{
console
.
info
(
"
Operation stopBackgroundRunning succeeded
"
);
console
.
info
(
"
Operation stopBackgroundRunning succeeded
"
);
...
...
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md
浏览文件 @
51634731
...
@@ -255,9 +255,9 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want
...
@@ -255,9 +255,9 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want
**示例**
:
**示例**
:
```
js
```
js
import
Ability
from
'
@ohos.application.Ability
'
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
backgroundTaskManager
from
'
@ohos.resourceschedule.backgroundTaskManager
'
;
import
backgroundTaskManager
from
'
@ohos.resourceschedule.backgroundTaskManager
'
;
import
wantAgent
from
'
@ohos.wantAgent
'
;
import
wantAgent
from
'
@ohos.
app.ability.
wantAgent
'
;
function
callback
(
error
,
data
)
{
function
callback
(
error
,
data
)
{
if
(
error
)
{
if
(
error
)
{
...
@@ -267,13 +267,13 @@ function callback(error, data) {
...
@@ -267,13 +267,13 @@ function callback(error, data) {
}
}
}
}
export
default
class
MainAbility
extends
Ability
{
export
default
class
EntryAbility
extends
UI
Ability
{
onCreate
(
want
,
launchParam
)
{
onCreate
(
want
,
launchParam
)
{
let
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
bundleName
:
"
com.example.myapplication
"
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
Main
Ability
"
abilityName
:
"
Entry
Ability
"
}
}
],
],
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
...
@@ -281,6 +281,7 @@ export default class MainAbility extends Ability {
...
@@ -281,6 +281,7 @@ export default class MainAbility extends Ability {
wantAgentFlags
:
[
wantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
wantAgentFlags
:
[
wantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
};
};
try
{
wantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
wantAgentObj
)
=>
{
wantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
wantAgentObj
)
=>
{
try
{
try
{
backgroundTaskManager
.
startBackgroundRunning
(
this
.
context
,
backgroundTaskManager
.
startBackgroundRunning
(
this
.
context
,
...
@@ -289,6 +290,9 @@ export default class MainAbility extends Ability {
...
@@ -289,6 +290,9 @@ export default class MainAbility extends Ability {
console
.
error
(
`Operation startBackgroundRunning failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
console
.
error
(
`Operation startBackgroundRunning failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
}
});
});
}
catch
(
error
)
{
console
.
error
(
`Operation getWantAgent failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
}
}
};
};
```
```
...
@@ -334,17 +338,17 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want
...
@@ -334,17 +338,17 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want
**示例**
:
**示例**
:
```
js
```
js
import
Ability
from
'
@ohos.application.Ability
'
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
backgroundTaskManager
from
'
@ohos.resourceschedule.backgroundTaskManager
'
;
import
backgroundTaskManager
from
'
@ohos.resourceschedule.backgroundTaskManager
'
;
import
wantAgent
from
'
@ohos.wantAgent
'
;
import
wantAgent
from
'
@ohos.
app.ability.
wantAgent
'
;
export
default
class
MainAbility
extends
Ability
{
export
default
class
EntryAbility
extends
UI
Ability
{
onCreate
(
want
,
launchParam
)
{
onCreate
(
want
,
launchParam
)
{
let
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
bundleName
:
"
com.example.myapplication
"
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
Main
Ability
"
abilityName
:
"
Entry
Ability
"
}
}
],
],
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
...
@@ -352,6 +356,7 @@ export default class MainAbility extends Ability {
...
@@ -352,6 +356,7 @@ export default class MainAbility extends Ability {
wantAgentFlags
:
[
wantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
wantAgentFlags
:
[
wantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
};
};
try
{
wantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
wantAgentObj
)
=>
{
wantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
wantAgentObj
)
=>
{
try
{
try
{
backgroundTaskManager
.
startBackgroundRunning
(
this
.
context
,
backgroundTaskManager
.
startBackgroundRunning
(
this
.
context
,
...
@@ -364,6 +369,9 @@ export default class MainAbility extends Ability {
...
@@ -364,6 +369,9 @@ export default class MainAbility extends Ability {
console
.
error
(
`Operation startBackgroundRunning failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
console
.
error
(
`Operation startBackgroundRunning failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
}
});
});
}
catch
(
error
)
{
console
.
error
(
`Operation getWantAgent failed. code is
${
error
.
code
}
message is
${
error
.
message
}
`
);
}
}
}
};
};
```
```
...
@@ -400,7 +408,7 @@ stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): vo
...
@@ -400,7 +408,7 @@ stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): vo
**示例**
:
**示例**
:
```
js
```
js
import
Ability
from
'
@ohos.application.Ability
'
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
backgroundTaskManager
from
'
@ohos.resourceschedule.backgroundTaskManager
'
;
import
backgroundTaskManager
from
'
@ohos.resourceschedule.backgroundTaskManager
'
;
function
callback
(
error
,
data
)
{
function
callback
(
error
,
data
)
{
...
@@ -411,7 +419,7 @@ function callback(error, data) {
...
@@ -411,7 +419,7 @@ function callback(error, data) {
}
}
}
}
export
default
class
MainAbility
extends
Ability
{
export
default
class
EntryAbility
extends
UI
Ability
{
onCreate
(
want
,
launchParam
)
{
onCreate
(
want
,
launchParam
)
{
try
{
try
{
backgroundTaskManager
.
stopBackgroundRunning
(
this
.
context
,
callback
);
backgroundTaskManager
.
stopBackgroundRunning
(
this
.
context
,
callback
);
...
@@ -461,10 +469,10 @@ stopBackgroundRunning(context: Context): Promise<void>
...
@@ -461,10 +469,10 @@ stopBackgroundRunning(context: Context): Promise<void>
**示例**
:
**示例**
:
```
js
```
js
import
Ability
from
'
@ohos.application.Ability
'
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
backgroundTaskManager
from
'
@ohos.resourceschedule.backgroundTaskManager
'
;
import
backgroundTaskManager
from
'
@ohos.resourceschedule.backgroundTaskManager
'
;
export
default
class
MainAbility
extends
Ability
{
export
default
class
EntryAbility
extends
UI
Ability
{
onCreate
(
want
,
launchParam
)
{
onCreate
(
want
,
launchParam
)
{
try
{
try
{
backgroundTaskManager
.
stopBackgroundRunning
(
this
.
context
).
then
(()
=>
{
backgroundTaskManager
.
stopBackgroundRunning
(
this
.
context
).
then
(()
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录