HarmonyOS Architecture, Features, and Service Card Development Guide
This article provides a comprehensive overview of HarmonyOS's layered architecture, key technical features, application development fundamentals, and step‑by‑step instructions for creating and configuring service cards, including code examples, debugging tips, common issues, and future development directions.
In early June 2021 Huawei released HarmonyOS 2.0, projecting hundreds of millions of devices to adopt the OS; as a deep partner, Beike introduced a lightweight, installation‑free service card that can be accessed directly from the service center without opening an app.
HarmonyOS follows a layered design: a microkernel‑based kernel layer, a system‑service layer that aggregates core capabilities, a framework layer offering multi‑language (Java, C/C++, JS) APIs and UI frameworks, and an application layer where apps consist of Feature Abilities (FA) with UI and Particle Abilities (PA) without UI.
The OS’s four major technical traits include a distributed architecture that enables seamless cross‑device collaboration, a deterministic latency engine and high‑performance IPC that reduce response delay by up to 25.7%, a microkernel security model that isolates services, and a unified IDE (DevEco Studio) that supports one‑click multi‑device deployment using Java or JS.
HarmonyOS apps are packaged as APP Packs containing one or more HAPs (HarmonyOS Ability Packages). HAPs are classified as entry (main modules) or feature (dynamic modules). Configuration files such as pack.info , config.json , and HAR describe abilities, permissions, and module metadata, similar to Android’s manifest.
To start development, install DevEco Studio, create a new project, and structure the project with resources , libs , and config.json . The article provides a full onCreateForm implementation for a service card, showing how to set layout resources, update the card, and handle click intents:
@Override
protected ProviderFormInfo onCreateForm(Intent intent) {
Image image = new Image(this);
String formName = intent.getStringParam(AbilitySlice.PARAM_FORM_NAME_KEY);
int formId = intent.getIntParam(AbilitySlice.PARAM_FORM_ID_KEY, -1);
int dimension = intent.getIntParam(AbilitySlice.PARAM_FORM_DIMENSION_KEY, DEFAULT_DIMENSION_2X2);
int resId = ResourceTable.Layout_form_list_pattern_house_list_card_2_2;
if (formName.equals("house_list_card")) {
switch (dimension) {
case DEFAULT_DIMENSION_2X2:
resId = ResourceTable.Layout_form_list_pattern_house_list_card_2_2;
break;
case DIMENSION_2X4:
resId = ResourceTable.Layout_form_list_pattern_house_list_card_2_4;
break;
}
}
ComponentProvider componentProvider = new ComponentProvider(resId, MainAbility.this);
componentProvider.setIntentAgent(ResourceTable.Id_title, openDetail());
componentProvider.setText(ResourceTable.Id_title_house1, "HarmonyOS");
componentProvider.setVisibility(ResourceTable.Id_empty_image, Component.HIDE);
componentProvider.setImagePixelMap(ResourceTable.Id_img_house1, pixelMap);
try {
updateForm(formId, componentProvider);
} catch (FormException e) {
e.printStackTrace();
}
return new ProviderFormInfo(resId, this);
}
private IntentAgent openDetail() {
Intent intent1 = new Intent();
Operation operation1 = new Intent.OperationBuilder()
.withDeviceId("")
.withBundleName("com.harmonyos.example")
.withAbilityName("com.harmonyos.example.ability.ListAbility")
.build();
intent1.setOperation(operation1);
Intent intent = new Intent();
Operation operation = new Intent.OperationBuilder()
.withDeviceId("")
.withBundleName("com.harmonyos.example")
.withAbilityName("com.harmonyos.example.ability.DetailAbility")
.build();
intent.setParam("from", "FACard");
intent.setOperation(operation);
intent.setParam("houseCode", actionUrl);
List
intentList = new ArrayList<>();
intentList.add(intent1);
intentList.add(intent);
List
flags = new ArrayList<>();
flags.add(IntentAgentConstant.Flags.UPDATE_PRESENT_FLAG);
flags.add(IntentAgentConstant.Flags.UPDATE_PRESENT_FLAG);
IntentAgentInfo paramsInfo = new IntentAgentInfo(requestCode,
IntentAgentConstant.OperationType.START_ABILITIES, flags, intentList, null);
IntentAgent intentAgent = IntentAgentHelper.getIntentAgent(this, paramsInfo);
return intentAgent;
}The config.json snippet defines the card’s layout, update schedule, dimensions, and type:
{
"forms": [
{
"landscapeLayouts": ["$layout:form_list_pattern_house_list_card_2_2", "$layout:form_list_pattern_house_list_card_2_4"],
"isDefault": true,
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*2",
"name": "house_list_card",
"description": "房源捡漏榜卡片",
"colorMode": "auto",
"type": "Java",
"supportDimensions": ["2*2", "2*4"],
"portraitLayouts": ["$layout:form_list_pattern_house_list_card_2_2", "$layout:form_list_pattern_house_list_card_2_4"],
"updateEnabled": true,
"updateDuration": 30
}
]
}To enable installation‑free cards, add the following to the module’s distro section:
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
}Layout development mirrors Android XML; the root layout must include ohos:remote="true" . A comparison table of common UI components (Toast, List, Image, etc.) is provided to help developers transition from Android.
Debugging can be performed on real devices (requiring a debug certificate) or emulators (no signing needed). The article also lists five frequently encountered issues with solutions, including third‑party SDK incompatibility, ScrollView height settings, WebView clear‑text traffic, Glide image loading on low‑resolution devices, and UnsatisfiedLinkError when creating cards without a running HAP.
Finally, the future roadmap emphasizes HarmonyOS’s “super terminal” concept, cross‑device data flow, and FA near‑field sharing for real‑estate scenarios, enabling seamless experiences across phones, TVs, and other smart devices.
Beike Product & Technology
As Beike's official product and technology account, we are committed to building a platform for sharing Beike's product and technology insights, targeting internet/O2O developers and product professionals. We share high-quality original articles, tech salon events, and recruitment information weekly. Welcome to follow us.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.