Setting the Icon and Name of a Mission Snapshot

Setting a unique icon and name for each mission snapshot of an application helps you better manage the missions and functions of the application.

By default, the icon and label fields in the abilities tag of the module.json5 file are used to set the icon and label.

Figure 1 Mission snapshot of a UIAbility

You can also use UIAbilityContext.setMissionIcon() and UIAbilityContext.setMissionLabel() 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.

This document describes the following operations:

Setting a Mission Snapshot Icon (for System Applications Only)

Call UIAbilityContext.setMissionIcon() to set the icon of a mission snapshot. The icon is an object of the PixelMap type. For details about how to obtain the context, see Obtaining the Context of UIAbility.

let imagePixelMap: PixelMap = undefined; // Obtain the PixelMap information.

context.setMissionIcon(imagePixelMap, (err) => {
  if (err.code) {
    console.error(`Failed to set mission icon. Code is ${err.code}, message is ${err.message}`);
  }
})

The display effect is shown below.

Figure 2 Mission snapshot icon

Setting a Mission Snapshot Name

Call UIAbilityContext.setMissionLabel() to set the name of a mission snapshot.

this.context.setMissionLabel('test').then(() => {
  console.info('Succeeded in seting mission label.');
}).catch((err) => {
  console.error(`Failed to set mission label. Code is ${err.code}, message is ${err.message}`);
});

The display effect is shown below.

Figure 3 Mission snapshot name