Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
33ed61f9
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,发现更多精彩内容 >>
提交
33ed61f9
编写于
12月 24, 2022
作者:
C
caochunlei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
caochunlei1@huawei.com
Signed-off-by:
N
caochunlei
<
caochunlei1@huawei.com
>
上级
3d6fc882
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
204 addition
and
80 deletion
+204
-80
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
...-dev/reference/apis/js-apis-app-ability-missionManager.md
+74
-25
zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md
...-dev/reference/apis/js-apis-application-missionManager.md
+69
-24
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionInfo.md
...v/reference/apis/js-apis-inner-application-missionInfo.md
+23
-12
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md
...ference/apis/js-apis-inner-application-missionListener.md
+8
-3
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md
...ference/apis/js-apis-inner-application-missionSnapshot.md
+30
-16
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
浏览文件 @
33ed61f9
...
...
@@ -20,7 +20,7 @@ ohos.permission.MANAGE_MISSIONS
on(type:"mission", listener: MissionListener): number;
注册系统任务状态监听。
注册系统任务状态监听
器
。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -32,13 +32,13 @@ on(type:"mission", listener: MissionListener): number;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listener | MissionListener | 是 | 系统任务监听
方法
。 |
| listener | MissionListener | 是 | 系统任务监听
器
。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| number | 监听
方法的index值,由系统创建,在注册系统任务状态监听时分配,和监听方法
一一对应
。 |
| number | 监听
器的index值,由系统创建,在注册系统任务状态监听时分配,和监听器
一一对应
。 |
**示例:**
...
...
@@ -51,7 +51,8 @@ var listener = {
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionMovedToFront-------
"
)},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
"
--------onMissionIconUpdated-------
"
)},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)}
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionLabelUpdated-------
"
)}
};
var
listenerId
=
-
1
;
...
...
@@ -105,7 +106,7 @@ export default class MainAbility extends UIAbility {
off(type: "mission", listenerId: number, callback: AsyncCallback
<
void
>
): void;
取消任务状态监听
。
解注册任务状态监听器
。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -117,7 +118,7 @@ off(type: "mission", listenerId: number, callback: AsyncCallback<void>): v
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listenerId | number | 是 | 系统任务状态监
听方法的index值,和监听方法一一对应,由registerMissionListener
方法返回。 |
| listenerId | number | 是 | 系统任务状态监
器法的index值,和监听器一一对应,由on
方法返回。 |
| callback | AsyncCallback
<
void
>
| 是 | 执行结果回调函数。 |
**示例:**
...
...
@@ -131,7 +132,8 @@ var listener = {
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionMovedToFront-------
"
)},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
"
--------onMissionIconUpdated-------
"
)},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)}
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionLabelUpdated-------
"
)}
};
var
listenerId
=
-
1
;
...
...
@@ -185,7 +187,7 @@ export default class MainAbility extends UIAbility {
off(type: "mission", listenerId: number): Promise
<
void
>
;
取消
任务状态监听,以promise方式返回执行结果。
解注册
任务状态监听,以promise方式返回执行结果。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -197,7 +199,7 @@ off(type: "mission", listenerId: number): Promise<void>;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listenerId | number | 是 | 系统任务状态监听
方法的index值,和监听方法一一对应,由registerMissionListener
方法返回。 |
| listenerId | number | 是 | 系统任务状态监听
器的index值,和监听器一一对应,由on
方法返回。 |
**返回值:**
...
...
@@ -216,7 +218,8 @@ var listener = {
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionMovedToFront-------
"
)},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
"
--------onMissionIconUpdated-------
"
)},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)}
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionLabelUpdated-------
"
)}
};
var
listenerId
=
-
1
;
...
...
@@ -292,7 +295,12 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M
try
{
var
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
missionManager
.
getMissionInfo
(
""
,
allMissions
[
0
].
missionId
,
(
error
,
mission
)
=>
{
console
.
log
(
"
getMissionInfo is called, error.code =
"
+
error
.
code
)
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
mission.missionId =
"
+
mission
.
missionId
);
console
.
log
(
"
mission.runningState =
"
+
mission
.
runningState
);
console
.
log
(
"
mission.lockedState =
"
+
mission
.
lockedState
);
...
...
@@ -369,7 +377,11 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Arr
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
})
...
...
@@ -442,13 +454,21 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getMissionSnapShot is called, error.code =
"
+
error
.
code
);
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
err
,
snapshot
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
"
getMissionInfos failed, err.code:
"
+
JSON
.
stringify
(
err
.
code
)
+
"
err.message:
"
+
JSON
.
stringify
(
err
.
message
));
return
;
}
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
...
...
@@ -507,7 +527,7 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnaps
getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback
\<
MissionSnapshot>): void;
使用给定的任务ID
获取任务低分辨率快照。
获取任务低分辨率快照。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -528,13 +548,21 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getLowResolutionMissionSnapShot is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getLowResolutionMissionSnapShot failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
...
...
@@ -548,7 +576,7 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise
\<
MissionSnapshot>;
使用给定的任务ID
获取任务低分辨率快照。
获取任务低分辨率快照。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -614,7 +642,12 @@ lockMission(missionId: number, callback: AsyncCallback<void>): void;
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -698,7 +731,11 @@ unlockMission(missionId: number, callback: AsyncCallback<void>): void;
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -785,7 +822,11 @@ clearMission(missionId: number, callback: AsyncCallback<void>): void;
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -917,7 +958,11 @@ moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -957,7 +1002,11 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall
```
ts
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md
浏览文件 @
33ed61f9
...
...
@@ -20,7 +20,7 @@ ohos.permission.MANAGE_MISSIONS
registerMissionListener(listener: MissionListener): number;
注册系统任务状态监听。
注册系统任务状态监听
器
。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -32,13 +32,13 @@ registerMissionListener(listener: MissionListener): number;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listener |
[
MissionListener
](
js-apis-inner-application-missionListener.md
)
| 是 | 系统任务监听
方法
。 |
| listener |
[
MissionListener
](
js-apis-inner-application-missionListener.md
)
| 是 | 系统任务监听
器
。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| number | 监听
方法的index值,由系统创建,在注册系统任务状态监听时分配,和监听方法
一一对应
。 |
| number | 监听
器的index值,由系统创建,在注册系统任务状态监听器时分配,和监听器
一一对应
。 |
**示例:**
...
...
@@ -61,7 +61,7 @@ var listenerid = missionManager.registerMissionListener(listener);
unregisterMissionListener(listenerId: number, callback: AsyncCallback
<
void
>
): void;
取消任务状态监听
。
解注册任务状态监听器
。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -73,7 +73,7 @@ unregisterMissionListener(listenerId: number, callback: AsyncCallback<void>
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listenerId | number | 是 | 系统任务状态监听
方法的index值,和监听方法
一一对应,由registerMissionListener方法返回。 |
| listenerId | number | 是 | 系统任务状态监听
器的index值,和监听器
一一对应,由registerMissionListener方法返回。 |
| callback | AsyncCallback
<
void
>
| 是 | 执行结果回调函数。 |
**示例:**
...
...
@@ -101,7 +101,7 @@ unregisterMissionListener(listenerId: number, callback: AsyncCallback<void>
unregisterMissionListener(listenerId: number): Promise
<
void
>
;
取消任务状态监听
,以promise方式返回执行结果。
反注册任务状态监听器
,以promise方式返回执行结果。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -113,7 +113,7 @@ unregisterMissionListener(listenerId: number): Promise<void>;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listenerId | number | 是 | 系统任务状态监听
方法的index值,和监听方法
一一对应,由registerMissionListener方法返回。 |
| listenerId | number | 是 | 系统任务状态监听
器的index值,和监听器
一一对应,由registerMissionListener方法返回。 |
**返回值:**
...
...
@@ -146,7 +146,7 @@ unregisterMissionListener(listenerId: number): Promise<void>;
getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback
<
MissionInfo
>
): void;
获取任务信息,以异步回调的方式返回任务信息。
获取
单个
任务信息,以异步回调的方式返回任务信息。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -169,7 +169,12 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M
var
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
missionManager
.
getMissionInfo
(
""
,
allMissions
[
0
].
missionId
,
(
error
,
mission
)
=>
{
console
.
log
(
"
getMissionInfo is called, error.code =
"
+
error
.
code
)
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
mission.missionId =
"
+
mission
.
missionId
);
console
.
log
(
"
mission.runningState =
"
+
mission
.
runningState
);
console
.
log
(
"
mission.lockedState =
"
+
mission
.
lockedState
);
...
...
@@ -184,7 +189,7 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M
getMissionInfo(deviceId: string, missionId: number): Promise
<
MissionInfo
>
;
获取任务信息,以promise方式返回任务信息。
获取
单个
任务信息,以promise方式返回任务信息。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -242,7 +247,11 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Arr
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
})
...
...
@@ -311,13 +320,21 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getMissionSnapShot is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionSnapShot failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
...
...
@@ -371,7 +388,7 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnaps
getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback
\<
MissionSnapshot>): void;
使用给定的任务ID
获取任务低分辨率快照。
获取任务低分辨率快照。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -393,13 +410,21 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getLowResolutionMissionSnapShot is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getLowResolutionMissionSnapShot failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
...
...
@@ -410,7 +435,7 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise
\<
MissionSnapshot>;
使用给定的任务ID
获取任务低分辨率快照。
获取任务低分辨率快照。
**需要权限**
:ohos.permission.MANAGE_MISSIONS
...
...
@@ -475,7 +500,11 @@ lockMission(missionId: number, callback: AsyncCallback<void>): void;
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -554,7 +583,11 @@ unlockMission(missionId: number, callback: AsyncCallback<void>): void;
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -637,7 +670,11 @@ clearMission(missionId: number, callback: AsyncCallback<void>): void;
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -768,7 +805,11 @@ moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
@@ -806,7 +847,11 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionInfo.md
浏览文件 @
33ed61f9
# MissionInfo
表示
Ability对应的任务
信息,可以通过
[
getMissionInfo
](
js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo
)
获取。
表示
任务的详细
信息,可以通过
[
getMissionInfo
](
js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo
)
获取。
**系统能力**
:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Mission
...
...
@@ -19,16 +19,27 @@
**示例:**
```
ts
import
missionManager
from
'
@ohos.app
lication
.missionManager
'
import
missionManager
from
'
@ohos.app
.ability
.missionManager
'
missionManager
.
getMissionInfo
(
"
12345
"
,
1
,
(
error
,
data
)
=>
{
console
.
info
(
'
getMissionInfo missionId is:
'
+
JSON
.
stringify
(
data
.
missionId
));
console
.
info
(
'
getMissionInfo runningState is:
'
+
JSON
.
stringify
(
data
.
runningState
));
console
.
info
(
'
getMissionInfo lockedState is:
'
+
JSON
.
stringify
(
data
.
lockedState
));
console
.
info
(
'
getMissionInfo timestamp is:
'
+
JSON
.
stringify
(
data
.
timestamp
));
console
.
info
(
'
getMissionInfo want is:
'
+
JSON
.
stringify
(
data
.
want
));
console
.
info
(
'
getMissionInfo label is:
'
+
JSON
.
stringify
(
data
.
label
));
console
.
info
(
'
getMissionInfo iconPath is:
'
+
JSON
.
stringify
(
data
.
iconPath
));
console
.
info
(
'
getMissionInfo continuable is:
'
+
JSON
.
stringify
(
data
.
continuable
));
});
try
{
missionManager
.
getMissionInfo
(
""
,
1
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
// 处理业务逻辑错误
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
'
getMissionInfo missionId is:
'
+
JSON
.
stringify
(
data
.
missionId
));
console
.
log
(
'
getMissionInfo runningState is:
'
+
JSON
.
stringify
(
data
.
runningState
));
console
.
log
(
'
getMissionInfo lockedState is:
'
+
JSON
.
stringify
(
data
.
lockedState
));
console
.
log
(
'
getMissionInfo timestamp is:
'
+
JSON
.
stringify
(
data
.
timestamp
));
console
.
log
(
'
getMissionInfo want is:
'
+
JSON
.
stringify
(
data
.
want
));
console
.
log
(
'
getMissionInfo label is:
'
+
JSON
.
stringify
(
data
.
label
));
console
.
log
(
'
getMissionInfo iconPath is:
'
+
JSON
.
stringify
(
data
.
iconPath
));
console
.
log
(
'
getMissionInfo continuable is:
'
+
JSON
.
stringify
(
data
.
continuable
));
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md
浏览文件 @
33ed61f9
# MissionListener
定义系统任务状态监听,可以通过
[
registerMissionListener
](
js-apis-application-missionManager.md#missionmanagerregistermissionlistener
)
注册。
定义系统任务状态监听,可以通过
[
on
](
js-apis-app-ability-missionManager.md#missionmanageron
)
注册。
**系统能力**
:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Mission
...
...
@@ -16,7 +16,7 @@
**示例:**
```
ts
import
missionManager
from
'
@ohos.app
lication
.missionManager
'
import
missionManager
from
'
@ohos.app
.ability
.missionManager
'
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
...
...
@@ -38,5 +38,10 @@ let listener = {
console
.
log
(
"
onMissionClosed mission:
"
+
JSON
.
stringify
(
mission
));
}
};
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
try
{
let
listenerId
=
missionManager
.
on
(
"
mission
"
,
listener
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md
浏览文件 @
33ed61f9
...
...
@@ -11,7 +11,7 @@
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | 是 | 是 | 表示
Ability任务元素名称
。 |
| ability | ElementName | 是 | 是 | 表示
该任务的组件信息
。 |
| snapshot |
[
image.PixelMap
](
js-apis-image.md
)
| 是 | 是 | 表示任务快照。 |
## 使用说明
...
...
@@ -20,19 +20,33 @@
**示例:**
```
ts
import
ElementName
from
'
@ohos.bundle
'
;
import
image
from
'
@ohos.multimedia.image
'
;
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
import
ElementName
from
'
@ohos.bundle
'
;
import
image
from
'
@ohos.multimedia.image
'
;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getMissionSnapShot is called, error.code =
"
+
error
.
code
);
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
err
,
snapshot
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
"
getMissionInfos failed, err.code:
"
+
JSON
.
stringify
(
err
.
code
)
+
"
err.message:
"
+
JSON
.
stringify
(
err
.
message
));
return
;
}
// 执行正常业务
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
})
}
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录