HarmonyOS/OpenHarmony application development-Stage model application/component-level configuration

When developing an application, it is necessary to configure some tags of the application, such as the application's package name, icon and other attributes identifying characteristics. This article describes some key tags that need to be configured when developing an application. Icons and labels are usually configured together, and can be divided into application icons, application labels and entry icons, and entry labels, which correspond to the icon and label labels in the app.json5 configuration file and module.json5 configuration file respectively. App icons and labels are used in the settings app, such as the app list in the settings app. The entry icon is displayed on the device desktop after the application is installed, as shown in Figure 1. The entry icon is based on UIAbility as the granularity, and supports multiple entry icons and labels for the same application. After clicking, it enters the corresponding UIAbility interface.

Figure 1  Application icons and labels

 

1. Application package name configuration

The application needs to configure the bundleName tag in the app.json5 configuration file under the AppScope directory of the project , which is used to identify the uniqueness of the application. It is recommended to use the reverse domain name format (for example, com.example.demo, it is recommended that the first level be the domain name suffix com, the second level be the manufacturer/personal name, and the third level be the application name, and multiple levels are also possible).

2. App icon and label configuration

The application of the Stage model needs to configure the application icon and application label. Application icons and labels are used in the settings application, for example, the application list in the settings application will display the corresponding icons and labels.

The application icon needs to configure the icon tag in the app.json5 configuration file under the AppScope directory of the project . The application icon needs to be configured as the resource index of the image. After the configuration is complete, the image becomes the application icon.

The application label needs to configure the label label in the app.json5 configuration file under the AppScope module of the project . Identifies the name displayed by the application to the user, and needs to be configured as an index of a string resource.

 {
    "app": {
      "icon": "$media:app_icon",
      "label": "$string:app_name"
      // ...
    }
  }

3. Entrance icon and label configuration

The Stage model supports configuring entry icons and entry labels for components. The portal icon and portal label are displayed on the desktop.

The entry icon needs to be configured in the module.json5 configuration file , and there is an icon tag under the abilities tag. For example, if you want to display the UIAbility icon on the desktop, you need to add "entity.system.home" to entities under the skills tag, and "action.system.home" to actions. When the same application has multiple UIAbilities and the above fields are configured, multiple icons will be displayed on the desktop, corresponding to their respective UIAbilities.

The entry label needs to be configured in the module.json5 configuration file , and there is a label label under the abilities label. For example, if you want to display the UIAbility icon on the desktop, you need to add "entity.system.home" to entities under the skills tag, and "action.system.home" to actions. When the same application has multiple UIAbilities to configure the above fields, multiple labels will be displayed on the desktop, corresponding to their respective UIAbilities.

{
  "module": {
    // ...
    "abilities": [
      {
        // $开头的为资源值
        "icon": "$media:icon",
        "label": "$string:EntryAbility_label",
        "skills": [
          {
            "entities": [
              "entity.system.home"
            ],
            "actions": [
              "action.system.home"
            ]
          }
        ],
      }
    ]
  }
}

4. Application version declaration configuration

The application version declaration needs to configure the versionCode tag and versionName tag in the app.json5 configuration file under the AppScope directory of the project . versionCode is used to identify the version number of the application, and the tag value is a 32-bit non-negative integer. This number is only used to determine if one version is newer than another, with higher numbers indicating higher versions. The versionName tag identifies the text description of the version number.

5. Device type configuration supported by Module

The device types supported by the Module need to configure the deviceTypes tag in the module.json5 configuration file . If a device is added to the deviceTypes tag, it indicates that the current Module supports running on the device.

6. Module permission configuration

The permission information required by the Module to access the system or other protected parts of the application needs to configure the requestPermission tag in the module.json5 configuration file . This tag is used to declare the name that needs to apply for permission, the reason for applying for permission, and the scenario where permission is used.

Guess you like

Origin blog.csdn.net/weixin_69135651/article/details/131556742