当前位置:网站首页>Share the basic knowledge of a common Hongmeng application
Share the basic knowledge of a common Hongmeng application
2022-07-02 02:35:00 【A drop in the universe】
What is Hongmeng application
User application generally refers to running on the operating system of the device , Programs that provide specific services to users , abbreviation “ application ”, abbreviation APP.
stay HarmonyOS Applications running on , There are two forms :
- Traditional applications that need to be installed .
- Provide specific functions , Installation free applications ( Atomized services ).
The form of Hongmeng application
Hongmeng application software package to APP Pack(Application Package) Form release , It is composed of one or more HAP(HarmonyOS Ability Package) And describe each HAP Attribute pack.info form .HAP yes [Ability] Deployment package for ,HarmonyOS Application code around Ability Component expansion .
Similar to the common Web application ,HAP Also by code 、 resources 、 Third party libraries and application configuration files .
HAP Can be divided into entry and feature Two module types :
- entry: The main module of the application . One APP in , There must be and only one for the same device type entry Type of HAP, It can be installed and operated independently .
- feature: Dynamic characteristic module of application . One APP Can contain one or more feature Type of HAP, It can also be without . Only contains Ability Of HAP To be able to run independently .

Ability
Ability( Ability , It can be interface capability , It can also be service capability ), It is the basic unit of application software . Abstraction of the capabilities of an application , An application can have multiple capabilities , That is, it can contain multiple Ability, Hongmeng HarmonyOS Support applications to Ability Deploy for the unit .
The library files
Library files are third-party code that applications rely on ( for example so、jar、bin、har Wait for binary ), Store in libs Catalog .
Resource file
The resource file is easy to understand : character string 、 picture 、 Icon 、 Audio etc. . Place in resources Under the table of contents .
resources
|---base // Default existing directory
| |---element
| | |---string.json
| |---media
| | |---icon.png
|---en_GB-vertical-car-mdpi // Examples of qualifier lists , Developers need to create their own
| |---element
| | |---string.json
| |---media
| | |---icon.png
|---rawfile // Default existing directory
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
For details, see Classification and use of resource files
The configuration file
Other under development , The configuration file format can be XML or JSON Format , Hongmeng application also adopts JSON Format , The configuration file is config.json . Configuration files are applied Ability Information , Used to declare the application Ability , And the permissions required by the application .
Each application HAP There is one in the root directory of “config.json” The configuration file , It mainly covers the following three aspects :
- Global configuration information for the application , Contains the package name of the application 、 Manufacturer 、 Basic information such as version number .
- Configuration information applied to specific devices .
- HAP Package configuration information , Include each Ability Basic properties that must be defined ( Such as package name 、 Class name 、 Type and Ability Capabilities provided ), As well as the permissions required for the application to access the system or other protected parts of the application .
This is from the last article HelloWorld In program config.json file :
{
"app": {
"bundleName":
"com.example.helloworld",
"vendor":
"example",
"version": {
"code":
1000000,
"name":
"1.0.0"
}
},
"deviceConfig": {},
"module": {
"package":
"com.example.helloworld",
"name":
".MyApplication",
"mainAbility":
"com.example.helloworld.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall":
true,
"moduleName":
"entry",
"moduleType":
"entry",
"installationFree":
false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation":
"unspecified",
"name":
"com.example.helloworld.MainAbility",
"icon":
"$media:icon",
"description":
"$string:mainability_description",
"label":
"$string:entry_MainAbility",
"type":
"page",
"launchType":
"standard"
}
]
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
For the explanation of the configuration file, please see : The elements of the configuration file
pack.info
Describe each in the application package HAP Properties of , from IDE Compile the generated , The application market unpacks and stores according to this document HAP Classified storage .HAP The specific properties of include :
- delivery-with-install: It means that we should HAP Whether to support installation with application .“true” Indicates that it supports installation with the application ;“false” Indicates that installation with application is not supported .
- name:HAP file name .
- module-type: Module type ,entry or feature .
- device-type: Expressed support for the HA P Type of equipment running .
HAR
HAR(HarmonyOS Ability Resources) It can provide all the content needed to build an application , Including source code 、 Resource files and config.json file .HAR differ HAP ,HAR It cannot be installed and run on the equipment independently , Can only be referenced as a dependency of an application module .
HelloWorld The overall structure of the project
- open HelloWorld After the project , stay Project The preview project structure in the left column is shown in the figure :

We can see that entry Catalog , This directory is actually an application HAP package , The type is entry type .
- Then we are src/main/java Next, you can see the folder named after the package : What is stored here is our Java Code . The code here can be used to create layouts 、 Dynamically adjust the layout and provide support services for interaction .
- and java Folder at the same level resources Application resources are distributed under the directory , The contents of this catalog are base Under the table of contents , According to the classification of resources, there are multiple folders .
- element: Represents an element resource , be lying json File format , It is mainly used to represent string 、 Color value 、 Boolean value , Can be quoted elsewhere .
- graphic: Paintable resources , use xml Documents to show , For example, the fillet button in the project 、 Button color .
- layout: Layout resources , For example, page layout resources
- media: Media resources , Including pictures 、 Audio and video and other non text format files
-
config.json: The configuration file

And main Catalog level test The directory is the test directory , It can be used to unit test the functions written by yourself , Ensure the correctness of the code .
And src A level one libs Directories are used to store or reference third-party packages , for example jar package 、so Bag, etc .
and entry Catalog level build The directory is used to store the final compiled package , That is to say HAP package .
summary
Through the above HelloWorld The application simply explains the files contained in a Hongmeng application 、 Project structure 、 And the functions of each module , Here is just a brief list of some knowledge , For more information, readers are advised to refer to the official documents to learn and understand .
Only familiar with one project structure , To know where to write the code as a developer , isn't it? ?
Hurry to learn . See you in the next article !
边栏推荐
- Realize the code scanning function of a custom layout
- [opencv] - comprehensive examples of five image filters
- Ten minutes will take you in-depth understanding of multithreading - multithreaded teamwork: synchronous control
- How to use redis ordered collection
- What are the characteristics of common web proxy IP
- A quick understanding of digital electricity
- How to hide the scroll bar of scroll view in uniapp
- 2022安全员-C证考试题及模拟考试
- Cesium dynamic diffusion point effect
- 【无标题】
猜你喜欢

Cesium dynamic diffusion point effect

Which brand of running headphones is good? How many professional running headphones are recommended

Actual battle of financial risk control - under Feature Engineering
![[graduation season] graduate seniors share how to make undergraduate more meaningful](/img/03/9adc44476e87b2499aa0ebb11cb247.png)
[graduation season] graduate seniors share how to make undergraduate more meaningful

批量检测url是否存在cdn—高准确率
![[question 008: what is UV in unity?]](/img/f7/5ee0b18d1fe21ff3b98518c46d9520.jpg)
[question 008: what is UV in unity?]
![[pit] how to understand](/img/e9/f5315a03b6f3da07021f915bb18af8.jpg)
[pit] how to understand "parameter fishing"

附加:信息脱敏;

QT实现界面跳转

Query word weight, search word weight calculation
随机推荐
结婚后
Types of exhibition items available in the multimedia interactive exhibition hall
【liuyubobobo-玩转Leetcode算法面试】【00】课程概述
Decipher the AI black technology behind sports: figure skating action recognition, multi-mode video classification and wonderful clip editing
LFM信号加噪、时频分析、滤波
What are the common proxy servers and what are the differences?
[learn C and fly] 2day Chapter 8 pointer (practice 8.1 password unlocking)
es面試題
How to turn off the LED light of Rog motherboard
[pit] how to understand "parameter fishing"
Feature query of hypergraph iserver rest Service
As a software testing engineer, will you choose the bank post? Laolao bank test post
es面试题
AR增强现实可应用的场景
STM32__05—PWM控制直流电机
The basic steps of using information theory to deal with scientific problems are
Ar Augmented Reality applicable scenarios
Software testing learning notes - network knowledge
How to use redis ordered collection
研发中台拆分过程的一些心得总结