• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# MissionSnapshot
2
3The **MissionSnapshot** module defines the snapshot of a mission. The snapshot can be obtained through [getMissionSnapShot](js-apis-app-ability-missionManager.md#missionmanagergetmissionsnapshot).
4
5> **NOTE**
6>
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.
8> The APIs of this module are system APIs and cannot be called by third-party applications.
9
10## Modules to Import
11
12```ts
13import missionManager from '@ohos.app.ability.missionManager';
14```
15
16**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
17
18| Name| Type| Readable| Writable| Description|
19| -------- | -------- | -------- | -------- | -------- |
20| ability | ElementName | Yes| Yes| Ability information of the mission.|
21| snapshot | [image.PixelMap](js-apis-image.md) | Yes| Yes| Snapshot of the mission.|
22
23## How to Use
24
25The mission snapshot information can be obtained by using **getMissionSnapShot** in **missionManager**.
26
27**Example**
28```ts
29import ElementName from '@ohos.bundle';
30import image from '@ohos.multimedia.image';
31import missionManager from '@ohos.application.missionManager';
32
33missionManager.getMissionInfos('', 10, (error, missions) => {
34  console.log('getMissionInfos is called, error.code = ' + error.code);
35  console.log('size = ' + missions.length);
36  console.log('missions = ' + JSON.stringify(missions));
37  let id = missions[0].missionId;
38
39  missionManager.getMissionSnapShot('', id, (error, snapshot) => {
40    console.log('getMissionSnapShot is called, error.code = ' + error.code);
41    console.log('bundleName = ' + snapshot.ability.bundleName);
42  });
43});
44```
45