• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Setting the Icon and Name of a Mission Snapshot
2
3Setting a unique icon and name for each mission snapshot of an application helps you better manage the missions and functions of the application.
4
5By default, the **icon** and **label** fields in the [abilities tag](../quick-start/module-configuration-file.md#abilities) of the [module.json5 file](../quick-start/module-configuration-file.md) are used to set the icon and label.
6
7Figure 1 Mission snapshot of a UIAbility
8![](figures/mission-list-recent.png)
9
10You can also use [UIAbilityContext.setMissionIcon()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionicon) and [UIAbilityContext.setMissionLabel()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionlabel) to customize the icon and name for a mission snapshot. For example, for a UIAbility instance in multiton mode, you can configure the icon and name for each mission snapshot based on different functions.
11
12This document describes the following operations:
13
14- [Setting a Mission Snapshot Icon (for System Applications Only)](#setting-a-mission-snapshot-icon-for-system-applications-only)
15- [Setting a Mission Snapshot Name](#setting-a-mission-snapshot-name)
16
17## Setting a Mission Snapshot Icon (for System Applications Only)
18
19Call [UIAbilityContext.setMissionIcon()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionicon) to set the icon of a mission snapshot. The icon is an object of the [PixelMap](../reference/apis/js-apis-image.md#pixelmap7) type. For details about how to obtain the context, see [Obtaining the Context of UIAbility](uiability-usage.md#obtaining-the-context-of-uiability).
20```ts
21let imagePixelMap: PixelMap = undefined; // Obtain the PixelMap information.
22
23context.setMissionIcon(imagePixelMap, (err) => {
24  if (err.code) {
25    console.error(`Failed to set mission icon. Code is ${err.code}, message is ${err.message}`);
26  }
27})
28```
29
30The display effect is shown below.
31
32Figure 2 Mission snapshot icon
33![](figures/mission-set-task-snapshot-icon.png)
34
35## Setting a Mission Snapshot Name
36
37Call [UIAbilityContext.setMissionLabel()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionlabel) to set the name of a mission snapshot.
38
39```ts
40this.context.setMissionLabel('test').then(() => {
41  console.info('Succeeded in seting mission label.');
42}).catch((err) => {
43  console.error(`Failed to set mission label. Code is ${err.code}, message is ${err.message}`);
44});
45```
46
47The display effect is shown below.
48
49Figure 3 Mission snapshot name
50![](figures/mission-set-task-snapshot-label.png)
51