Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
35308406
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看板
提交
35308406
编写于
1月 06, 2023
作者:
C
caochunlei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
caochunlei1@huawei.com
Signed-off-by:
N
caochunlei
<
caochunlei1@huawei.com
>
上级
8dc829f2
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
283 addition
and
323 deletion
+283
-323
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
...-dev/reference/apis/js-apis-app-ability-missionManager.md
+283
-323
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
浏览文件 @
35308406
...
...
@@ -9,7 +9,7 @@ missionManager模块提供系统任务管理能力,包括对系统任务执行
## 导入模块
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
```
## 权限列表
...
...
@@ -43,6 +43,7 @@ on(type:"mission", listener: MissionListener): number;
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
var
listener
=
{
...
...
@@ -59,7 +60,7 @@ var listenerId = -1;
export
default
class
MainAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
"
[Demo] MainAbility onCreate
"
)
console
.
log
(
"
[Demo] MainAbility onCreate
"
)
;
globalThis
.
abilityWant
=
want
;
globalThis
.
context
=
this
.
context
;
}
...
...
@@ -124,6 +125,7 @@ off(type: "mission", listenerId: number, callback: AsyncCallback<void>): v
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
var
listener
=
{
...
...
@@ -210,6 +212,7 @@ off(type: "mission", listenerId: number): Promise<void>;
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
var
listener
=
{
...
...
@@ -292,21 +295,27 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
1
;
try
{
var
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
missionManager
.
getMissionInfo
(
""
,
allMissions
[
0
].
missionId
,
(
error
,
mission
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
var
allMissions
=
await
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
if
(
allMissions
&&
allMissions
.
length
>
0
)
{
testMissionId
=
allMissions
[
0
].
missionId
;
}
missionManager
.
getMissionInfo
(
""
,
testMissionId
,
(
error
,
mission
)
=>
{
if
(
error
)
{
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
}
else
{
console
.
log
(
"
mission.missionId =
"
+
mission
.
missionId
);
console
.
log
(
"
mission.runningState =
"
+
mission
.
runningState
);
console
.
log
(
"
mission.lockedState =
"
+
mission
.
lockedState
);
console
.
log
(
"
mission.timestamp =
"
+
mission
.
timestamp
);
console
.
log
(
"
mission.label =
"
+
mission
.
label
);
console
.
log
(
"
mission.iconPath =
"
+
mission
.
iconPath
);
}
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
...
...
@@ -341,16 +350,20 @@ getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>;
**示例:**
```
ts
try
{
var
mission
=
missionManager
.
getMissionInfo
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
1
;
try
{
missionManager
.
getMissionInfo
(
""
,
testMissionId
).
then
((
data
)
=>
{
console
.
info
(
'
getMissionInfo successfully. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
error
(
'
getMissionInfo failed. Cause:
'
+
error
.
message
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
}
catch
(
error
)
{
console
.
error
(
'
getMissionInfo failed. Cause:
'
+
error
.
message
);
}
```
## missionManager.getMissionInfos
...
...
@@ -375,15 +388,17 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Arr
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
if
(
error
)
{
console
.
log
(
"
getMissionInfo
s
failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
return
;
}
}
else
{
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
}
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
...
...
@@ -418,16 +433,19 @@ getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionIn
**示例:**
```
ts
try
{
var
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
).
then
((
data
)
=>
{
console
.
info
(
'
getMissionInfos successfully. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
error
(
'
getMissionInfos failed. Cause:
'
+
error
.
message
);
});
}
catch
(
error
)
{
console
.
error
(
'
getMissionInfos failed. Cause:
'
+
error
.
message
);
}
```
## missionManager.getMissionSnapShot
...
...
@@ -450,33 +468,22 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
| callback | AsyncCallback
<
[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)
>
| 是 | 执行结果回调函数,返回任务快照信息。 |
**示例:**
```
ts
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
,
(
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
);
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
2
;
try
{
missionManager
.
getMissionSnapShot
(
""
,
testMissionId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
getMissionSnapShot failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
getMissionSnapShot successfully:
'
+
JSON
.
stringify
(
data
));
}
```
});
}
catch
(
err
)
{
console
.
error
(
'
getMissionSnapShot failed:
'
+
err
.
message
);
}
```
## missionManager.getMissionSnapShot
...
...
@@ -504,24 +511,20 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnaps
| Promise
<
[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)
>
| 任务快照信息。 |
**示例:**
```
ts
try
{
var
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
var
id
=
allMissions
[
0
].
missionId
;
var
snapshot
=
missionManager
.
getMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
2
;
try
{
missionManager
.
getMissionSnapShot
(
""
,
testMissionId
).
then
((
data
)
=>
{
console
.
info
(
'
getMissionSnapShot successfully. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
error
(
'
getMissionSnapShot failed. Cause:
'
+
error
.
message
);
});
}
catch
(
paramE
rror
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramE
rror
.
message
);
}
```
}
catch
(
e
rror
)
{
console
.
error
(
'
getMissionSnapShot failed. Cause:
'
+
e
rror
.
message
);
}
```
## missionManager.getLowResolutionMissionSnapShot
...
...
@@ -544,33 +547,22 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
| callback | AsyncCallback
<
[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)
>
| 是 | 执行结果回调函数,返回任务快照信息。 |
**示例:**
```
ts
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
.
getLowResolutionMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
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
);
})
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
2
;
try
{
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
testMissionId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
getLowResolutionMissionSnapShot failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
getLowResolutionMissionSnapShot successfully:
'
+
JSON
.
stringify
(
data
));
}
```
});
}
catch
(
err
)
{
console
.
error
(
'
getLowResolutionMissionSnapShot failed:
'
+
err
.
message
);
}
```
## missionManager.getLowResolutionMissionSnapShot
...
...
@@ -599,23 +591,20 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\<M
**示例:**
```
ts
try
{
var
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
var
id
=
allMissions
[
0
].
missionId
;
var
snapshot
=
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
2
;
try
{
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
testMissionId
).
then
((
data
)
=>
{
console
.
info
(
'
getLowResolutionMissionSnapShot successfully. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
error
(
'
getLowResolutionMissionSnapShot failed. Cause:
'
+
error
.
message
);
});
}
catch
(
paramE
rror
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramE
rror
.
message
);
}
```
}
catch
(
e
rror
)
{
console
.
error
(
'
getLowResolutionMissionSnapShot failed. Cause:
'
+
e
rror
.
message
);
}
```
## missionManager.lockMission
...
...
@@ -639,28 +628,22 @@ lockMission(missionId: number, callback: AsyncCallback<void>): void;
**示例:**
```
ts
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
;
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
2
;
try
{
missionManager
.
lockMission
(
testMissionId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
lockMission failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
lockMission successfully:
'
+
JSON
.
stringify
(
data
));
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
then
(()
=>
{
console
.
log
(
"
lockMission is called
"
);
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
}
catch
(
err
)
{
console
.
error
(
'
lockMission failed:
'
+
err
.
message
);
}
```
## missionManager.lockMission
...
...
@@ -687,25 +670,20 @@ lockMission(missionId: number): Promise<void>;
| Promise
<
void
>
| promise方式返回执行结果。 |
**示例:**
```
ts
try
{
var
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
var
id
=
allMissions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
2
;
try
{
missionManager
.
lockMission
(
testMissionId
).
then
((
data
)
=>
{
console
.
info
(
'
lockMission successfully. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
error
(
'
lockMission failed. Cause:
'
+
error
.
message
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
}
catch
(
error
)
{
console
.
error
(
'
lockMission failed. Cause:
'
+
error
.
message
);
}
```
## missionManager.unlockMission
...
...
@@ -727,28 +705,22 @@ unlockMission(missionId: number, callback: AsyncCallback<void>): void;
| callback | AsyncCallback
<
void
>
| 是 | 执行结果回调函数。 |
**示例:**
```
ts
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
;
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
2
;
try
{
missionManager
.
unlockMission
(
testMissionId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
unlockMission failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
unlockMission successfully:
'
+
JSON
.
stringify
(
data
));
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
unlockMission
(
id
).
then
(()
=>
{
console
.
log
(
"
unlockMission is called
"
);
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
}
catch
(
err
)
{
console
.
error
(
'
unlockMission failed:
'
+
err
.
message
);
}
```
## missionManager.unlockMission
...
...
@@ -776,27 +748,20 @@ unlockMission(missionId: number): Promise<void>;
**示例:**
```
ts
try
{
var
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
var
id
=
allMissions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
missionManager
.
unlockMission
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
2
;
try
{
missionManager
.
unlockMission
(
testMissionId
).
then
((
data
)
=>
{
console
.
info
(
'
unlockMission successfully. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
error
(
'
unlockMission failed. Cause:
'
+
error
.
message
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
}
catch
(
error
)
{
console
.
error
(
'
unlockMission failed. Cause:
'
+
error
.
message
);
}
```
## missionManager.clearMission
...
...
@@ -819,26 +784,22 @@ clearMission(missionId: number, callback: AsyncCallback<void>): void;
**示例:**
```
ts
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
;
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
2
;
try
{
missionManager
.
clearMission
(
testMissionId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
clearMission failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
clearMission successfully:
'
+
JSON
.
stringify
(
data
));
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
clearMission
(
id
).
then
(()
=>
{
console
.
log
(
"
clearMission is called
"
);
});
});
}
catch
(
paramErro
r
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramErro
r
.
message
);
}
```
}
catch
(
er
r
)
{
console
.
error
(
'
clearMission failed:
'
+
er
r
.
message
);
}
```
## missionManager.clearMission
...
...
@@ -867,24 +828,20 @@ clearMission(missionId: number): Promise<void>;
**示例:**
```
ts
try
{
var
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
var
id
=
allMissions
[
0
].
missionId
;
missionManager
.
clearMission
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
2
;
try
{
missionManager
.
clearMission
(
testMissionId
).
then
((
data
)
=>
{
console
.
info
(
'
clearMission successfully. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
error
(
'
clearMission failed. Cause:
'
+
error
.
message
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
}
catch
(
error
)
{
console
.
error
(
'
clearMission failed. Cause:
'
+
error
.
message
);
}
```
## missionManager.clearAllMissions
...
...
@@ -900,12 +857,21 @@ clearAllMissions(callback: AsyncCallback<void>): void;
**示例:**
```
ts
missionManager
.
clearAllMissions
().
then
(()
=>
{
console
.
log
(
"
clearAllMissions is called
"
);
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
clearAllMissions
(
err
=>
{
if
(
err
)
{
console
.
error
(
'
clearAllMissions failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
clearAllMissions successfully.
'
);
}
});
```
}
catch
(
err
)
{
console
.
error
(
'
clearAllMissions failed:
'
+
err
.
message
);
}
```
## missionManager.clearAllMissions
...
...
@@ -927,12 +893,19 @@ clearAllMissions(): Promise<void>;
**示例:**
```
ts
missionManager
.
clearAllMissions
().
catch
(
function
(
err
){
console
.
log
(
err
);
});
```
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
clearAllMissions
(
bundleName
).
then
(()
=>
{
console
.
info
(
'
clearAllMissions successfully.
'
);
}).
catch
(
err
=>
{
console
.
error
(
'
clearAllMissions failed:
'
+
err
.
message
);
});
}
catch
(
err
)
{
console
.
error
(
'
clearAllMissions failed:
'
+
err
.
message
);
}
```
## missionManager.moveMissionToFront
...
...
@@ -955,27 +928,22 @@ moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void
**示例:**
```
ts
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
;
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
2
;
try
{
missionManager
.
moveMissionToFront
(
testMissionId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
moveMissionToFront failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
moveMissionToFront successfully:
'
+
JSON
.
stringify
(
data
));
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
).
then
(()
=>
{
console
.
log
(
"
moveMissionToFront is called
"
);
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
}
catch
(
err
)
{
console
.
error
(
'
moveMissionToFront failed:
'
+
err
.
message
);
}
```
## missionManager.moveMissionToFront
...
...
@@ -999,27 +967,22 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall
**示例:**
```
ts
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
;
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
2
;
try
{
missionManager
.
moveMissionToFront
(
testMissionId
,
{
windowMode
:
101
},
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
moveMissionToFront failed:
'
+
err
.
message
);
}
else
{
console
.
info
(
'
moveMissionToFront successfully:
'
+
JSON
.
stringify
(
data
));
}
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
,{
windowMode
:
101
}).
then
(()
=>
{
console
.
log
(
"
moveMissionToFront is called
"
);
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
```
}
catch
(
err
)
{
console
.
error
(
'
moveMissionToFront failed:
'
+
err
.
message
);
}
```
## missionManager.moveMissionToFront
...
...
@@ -1048,20 +1011,17 @@ moveMissionToFront(missionId: number, options?: StartOptions): Promise<void&g
**示例:**
```
ts
try
{
var
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
var
id
=
allMissions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
let
testMissionId
=
2
;
try
{
missionManager
.
moveMissionToFront
(
testMissionId
).
then
((
data
)
=>
{
console
.
info
(
'
moveMissionToFront successfully. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
error
(
'
moveMissionToFront failed. Cause:
'
+
error
.
message
);
});
}
catch
(
paramE
rror
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramE
rror
.
message
);
}
```
}
catch
(
e
rror
)
{
console
.
error
(
'
moveMissionToFront failed. Cause:
'
+
e
rror
.
message
);
}
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录