js-apis-application-MissionSnapshot.md 1.5 KB
Newer Older
W
wusongqing 已提交
1 2
# MissionSnapshot

W
wusongqing 已提交
3 4
The **MissionSnapshot** module provides the mission snapshot information of an ability.

W
wusongqing 已提交
5
> **NOTE**
W
wusongqing 已提交
6
> 
W
wusongqing 已提交
7
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
W
wusongqing 已提交
8
> The APIs of this module are system APIs and cannot be called by third-party applications.
W
wusongqing 已提交
9

W
wusongqing 已提交
10
## Usage
W
wusongqing 已提交
11

W
wusongqing 已提交
12
The mission snapshot information can be obtained by using **getMissionSnapShot** in **missionManager**.
W
wusongqing 已提交
13

W
wusongqing 已提交
14
```js
W
wusongqing 已提交
15 16
import ElementName from '@ohos.bundle';
import image from '@ohos.multimedia.image';
G
Gloria 已提交
17
import missionManager from '@ohos.application.missionManager';
W
wusongqing 已提交
18

G
Gloria 已提交
19 20 21 22 23
missionManager.getMissionInfos("", 10, (error, missions) => {
  console.log("getMissionInfos is called, error.code = " + error.code);
  console.log("size = " + missions.length);
  console.log("missions = " + JSON.stringify(missions));
  var id = missions[0].missionId;
W
wusongqing 已提交
24

G
Gloria 已提交
25 26 27
  missionManager.getMissionSnapShot("", id, (error, snapshot) => {
    console.log("getMissionSnapShot is called, error.code = " + error.code);
    console.log("bundleName = " + snapshot.ability.bundleName);
W
wusongqing 已提交
28
  })
G
Gloria 已提交
29
})
W
wusongqing 已提交
30
```
W
wusongqing 已提交
31 32 33 34
## MissionSnapshot

Describes the mission snapshot.

W
wusongqing 已提交
35 36
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission

W
wusongqing 已提交
37
| Name| Type| Readable| Writable| Description|
W
wusongqing 已提交
38
| -------- | -------- | -------- | -------- | -------- |
W
wusongqing 已提交
39 40
| ability | ElementName | Yes| Yes| Information that matches an ability.|
| snapshot | [image.PixelMap](js-apis-image.md) | Yes| Yes| Snapshot of the mission.|