当前位置:网站首页>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 !
边栏推荐
- Webgpu (I): basic concepts
- Set status bar color
- What kind of good and cost-effective Bluetooth sports headset to buy
- Calculation (computer) code of suffix expression
- 2022 low voltage electrician test question simulation test question bank simulation test platform operation
- Deployment practice and problem solving of dash application development environment based on jupyter Lab
- The basic steps of using information theory to deal with scientific problems are
- The middle element and the rightmost element of the shutter
- 【做题打卡】集成每日5题分享(第二期)
- [learn C and fly] day 5 chapter 2 program in C language (Exercise 2)
猜你喜欢

Which brand of sports headset is better? Bluetooth headset suitable for sports

结婚后

Types of exhibition items available in the multimedia interactive exhibition hall

Is bone conduction earphone better than traditional earphones? The sound production principle of bone conduction earphones is popular science

Build a modern data architecture on the cloud with Amazon AppFlow, Amazon lake formation and Amazon redshift

【OpenCV】-5种图像滤波的综合示例

Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved

Decipher the AI black technology behind sports: figure skating action recognition, multi-mode video classification and wonderful clip editing

Cesium dynamic diffusion point effect

New programmer magazine | Li Penghui talks about open source cloud native message flow system
随机推荐
2022低压电工考试题模拟考试题库模拟考试平台操作
A quick understanding of digital electricity
JVM面试篇
C return multiple values getter setter queries the database and adds the list return value to the window
C # use system data. The split mixed mode assembly is generated for the "v2.0.50727" version of the runtime, and it cannot be loaded in the 4.0 runtime without configuring other information
An analysis of circuit for quick understanding
[opencv] - comprehensive examples of five image filters
Kibana操控ES
2022 safety officer-c certificate examination questions and mock examination
STM32__05—PWM控制直流电机
Ar Augmented Reality applicable scenarios
No programming code technology! Four step easy flower store applet
Actual battle of financial risk control - under Feature Engineering
Email picture attachment
how to come in an investnent bank team
超图iServer rest服务之feature查询
CoordinatorLayout + TabLayout + ViewPager2(里面再嵌套一个RecyclerView),RecyclerView的滑动冲突解决
[question 008: what is UV in unity?]
Software testing learning notes - network knowledge
What kind of good and cost-effective Bluetooth sports headset to buy