Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
20a85969
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
20a85969
编写于
6月 16, 2023
作者:
W
wangyong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update doc of moveMissionsToForegound/moveMissionsToBackground
Signed-off-by:
N
wangyong
<
wangyong5@huawei.com
>
上级
2b1bcabc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
312 addition
and
0 deletion
+312
-0
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
...-dev/reference/apis/js-apis-app-ability-missionManager.md
+312
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
浏览文件 @
20a85969
...
...
@@ -1098,3 +1098,315 @@ try {
console
.
error
(
'
moveMissionToFront failed. Cause: ${error.message}
'
);
}
```
## missionManager.moveMissionsToForeground<sup>10+</sup>
moveMissionsToForeground(missionIds: Array
<
number
>
, callback: AsyncCallback
<
void
>
): void;
将指定任务批量切到前台,以回调函数的方式返回。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Mission
**系统接口**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| missionIds | Array
<
number
>
| 是 | 任务ID数组。 |
| callback | AsyncCallback
<
void
>
| 是 | 执行结果回调函数。 |
**错误码**
:
以下错误码的详细介绍请参见
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
。
| 错误码ID | 错误信息 |
| ------- | -------- |
| 16000050 | Internal error. |
**示例:**
```
ts
import
abilityManager
from
'
@ohos.app.ability.abilityManager
'
;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missionInfos
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
));
return
;
}
if
(
missionInfos
.
length
<
1
)
{
return
;
}
let
toShows
=
new
Array
<
number
>
();
for
(
let
missionInfo
of
missionInfos
)
{
if
(
missionInfo
.
abilityState
==
abilityManager
.
AbilityState
.
BACKGROUND
)
{
toShows
.
push
(
missionInfo
.
missionId
);
}
}
missionManager
.
moveMissionsToForeground
(
toShows
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
moveMissionsToForeground failed: ${err.message}
'
);
}
else
{
console
.
info
(
'
moveMissionsToForeground successfully: ${JSON.stringify(data)}
'
);
}
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
## missionManager.moveMissionsToForeground<sup>10+</sup>
moveMissionsToForeground(missionIds: Array
<
number
>
, topMission: number, callback: AsyncCallback
<
void
>
): void;
将指定任务批量切换到前台,并将任务ID等于topMission的任务移动到最顶层,以回调函数的方式返回。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Mission
**系统接口**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| missionIds | Array
<
number
>
| 是 | 任务ID数组。 |
| topMission | number | 是 | 待移动到最顶层的任务ID |
| callback | AsyncCallback
<
void
>
| 是 | 执行结果回调函数。 |
**错误码**
:
以下错误码的详细介绍请参见
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
。
| 错误码ID | 错误信息 |
| ------- | -------- |
| 16000050 | Internal error. |
**示例:**
```
ts
import
abilityManager
from
'
@ohos.app.ability.abilityManager
'
;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missionInfos
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
));
return
;
}
if
(
missionInfos
.
length
<
1
)
{
return
;
}
let
toShows
=
new
Array
<
number
>
();
for
(
let
missionInfo
of
missionInfos
)
{
if
(
missionInfo
.
abilityState
==
abilityManager
.
AbilityState
.
BACKGROUND
)
{
toShows
.
push
(
missionInfo
.
missionId
);
}
}
missionManager
.
moveMissionsToForeground
(
toShows
,
toShows
[
0
],
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
moveMissionsToForeground failed: ${err.message}
'
);
}
else
{
console
.
info
(
'
moveMissionsToForeground successfully: ${JSON.stringify(data)}
'
);
}
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
## missionManager.moveMissionsToForeground<sup>10+</sup>
moveMissionsToForeground(missionIds: Array
<
number
>
, topMission?: number): Promise
<
void
>
;
将指定任务批量切到前台,并将任务ID等于topMission的任务移动到最顶层,以promise的方式返回。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Mission
**系统接口**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| missionIds | Array
<
number
>
| 是 | 任务ID数组。 |
| topMission | number | 否 | 待移动到最顶层的任务ID |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
void
>
| promise方式返回执行结果。 |
**错误码**
:
以下错误码的详细介绍请参见
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
。
| 错误码ID | 错误信息 |
| ------- | -------- |
| 16000050 | Internal error. |
**示例:**
```
ts
import
abilityManager
from
'
@ohos.app.ability.abilityManager
'
;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missionInfos
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
));
return
;
}
if
(
missionInfos
.
length
<
1
)
{
return
;
}
let
toShows
=
new
Array
<
number
>
();
for
(
let
missionInfo
of
missionInfos
)
{
if
(
missionInfo
.
abilityState
==
abilityManager
.
AbilityState
.
BACKGROUND
)
{
toShows
.
push
(
missionInfo
.
missionId
);
}
}
missionManager
.
moveMissionsToForeground
(
toShows
,
toShows
[
0
]).
then
(()
=>
{
console
.
log
(
"
moveMissionsToForeground is called
"
);
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
## missionManager.moveMissionsToBackground<sup>10+</sup>
moveMissionsToBackground(missionIds: Array
<
number
>
, callback: AsyncCallback
<
Array
<
number
>>
): void;
将指定任务批量切到后台,以回调函数的方式返回, 返回的结果任务ID按被隐藏时的任务层级排序。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Mission
**系统接口**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| missionIds | Array
<
number
>
| 是 | 任务ID数组。 |
| callback | AsyncCallback
<
Array
<
number
>>
| 是 | 执行结果回调函数。 |
**错误码**
:
以下错误码的详细介绍请参见
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
。
| 错误码ID | 错误信息 |
| ------- | -------- |
| 16000050 | Internal error. |
**示例:**
```
ts
import
abilityManager
from
'
@ohos.app.ability.abilityManager
'
;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missionInfos
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
));
return
;
}
let
toHides
=
new
Array
<
number
>
();
for
(
let
missionInfo
of
missionInfos
)
{
if
(
missionInfo
.
abilityState
==
abilityManager
.
AbilityState
.
FOREGROUND
)
{
toHides
.
push
(
missionInfo
.
missionId
);
}
}
missionManager
.
moveMissionsToBackground
(
toHides
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
moveMissionsToBackground failed: ${err.message}
'
);
}
else
{
console
.
info
(
'
moveMissionsToBackground successfully: ${JSON.stringify(data)}
'
);
}
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
## missionManager.moveMissionsToBackground<sup>10+</sup>
moveMissionsToBackground(missionIds : Array
<
number
>
): Promise
<
Array
<
number
>>
;
将指定任务批量切到后台,以promise的方式返回, 返回的结果按被隐藏时的任务层级排序。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Mission
**系统接口**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| missionIds | Array
<
number
>
| 是 | 任务ID数组。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
Array
<
number
>>
| promise方式返回执行结果。 |
**错误码**
:
以下错误码的详细介绍请参见
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
。
| 错误码ID | 错误信息 |
| ------- | -------- |
| 16000050 | Internal error. |
**示例:**
```
ts
import
abilityManager
from
'
@ohos.app.ability.abilityManager
'
;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missionInfos
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
));
return
;
}
let
toHides
=
new
Array
<
number
>
();
for
(
let
missionInfo
of
missionInfos
)
{
if
(
missionInfo
.
abilityState
==
abilityManager
.
AbilityState
.
FOREGROUND
)
{
toHides
.
push
(
missionInfo
.
missionId
);
}
}
missionManager
.
moveMissionsToBackground
(
toHides
).
then
((
hideRes
)
=>
{
console
.
log
(
"
moveMissionsToBackground is called, res:
"
+
JSON
.
stringify
(
hideRes
));
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录