HarmonyOS N-API Module Loading in Main Thread
Module Loading Overview
The Node-API napi_load_module intreface enables module loading in the main thread. After loading, developers can retrieve exported properties using napi_get_property or access functions via napi_get_named_property. Supported scenarios include:
Loading system modules (e.g., @ohos.hilog)
Loading modules from ArkTS files
...
Posted on Fri, 31 Jul 2026 16:08:29 +0000 by himnbandit
Working with XML in HarmonyOS ArkTS: Structure Definition and Processing
An XML element consists of three main parts:
Tag: Marks the begining and end of an element
Attributes: Provide additional information about the element
Content: The data contained within the element
Element Structure Example
<book category="fiction">
<title>XML Fundamentals</title>
<author>Jane Smith</ ...
Posted on Fri, 24 Jul 2026 16:39:15 +0000 by bagsobrands
AOP in the HarmonyOS Architecture
Introduction to AOP
For developers familiar with Android or Java Web development, the concept of Aspect-Oriented Programming (AOP) is well-established. The core of AOP lies in identifying an aspect and then performing pre-processing or post-processing on a specific business operation, or even replacing the operation entirely. The granularity of ...
Posted on Thu, 16 Jul 2026 16:26:55 +0000 by gtibok
Implementing Persistent Worker Threads in HarmonyOS
In HarmonyOS, while TaskPool is ideal for short-lived, independent tasks, scenarios requiring long-lived state or persistent object handles often necessitate the use of Worker threads. Unlike TaskPool, which manages task lifecycles automatically, Worker allows for maintaining a single, consistent execution context.
Creating and Managing a Worke ...
Posted on Mon, 13 Jul 2026 16:51:23 +0000 by Merdok
Building Grid Layouts in HarmonyOS with Grid and GridItem
To create responsive grid layouts in HarmonyOS, developers use the Grid container along with GridItem children. This approach supports flexible sizing, spacing, direction control, and even pagination.
Defining Rows and Columns with Templates
The structure of a grid is defined using rowsTemplate and columnsTemplate, which accept CSS-like fractio ...
Posted on Wed, 01 Jul 2026 17:59:05 +0000 by aka_bigred
Managing Application Context in HarmonyOS Stage Model
Overview of Context TypesIn the HarmonyOS Stage model, Context provides access to application resources, paths, and configurations. Several specialized context classes inherit from the base Context class, including ApplicationContext, AbilityStageContext, UIAbilityContext, and ExtensionContext. These subclasses provide specific capabilities whi ...
Posted on Thu, 25 Jun 2026 17:40:44 +0000 by thewomb
Implementing Tab Navigation in HarmonyOS Applications
Bottom Navigation Bar
@Entry
@Component
struct MainScreen {
build() {
Column() {
Tabs({ barPosition: BarPosition.End }) {
TabContent() {
Text('Home Screen').fontSize(30)
}.tabBar('Home')
TabContent() {
Text('Discovery Screen').fontSize(30)
}.tabBar('Discovery')
TabContent ...
Posted on Tue, 23 Jun 2026 17:09:58 +0000 by rich1983
Exporting C++ Class Objects via Node-API and Managing Their Lifecycle
Sample Project Source Code Analysis
The sample project uses a Native C++ template with the Stage model. This analysis focuses on key implementation files for class object export and lifecycle management.
Class Definition and Method Implementation
NapiTest.h Header File
#ifndef __NAPI_TEST_H__
#define __NAPI_TEST_H__
#include "napi/native_ ...
Posted on Thu, 11 Jun 2026 18:28:49 +0000 by itworks
Implementing Custom Notifications in HarmonyOS
Overview
This example demonstrates how to create and manage various types of notifications using @ohos.notificationManager and related APIs. It covers publishing, canceling, and setting badge counts on the desktop for different notification formats including basic, long text, multi-line, image-based, button-enabled, and app-launching notificati ...
Posted on Sat, 06 Jun 2026 17:39:35 +0000 by forcer
Working with Application Context in HarmonyOS Stage Model
In the Stage model, different contexts offer varying scopes of data and capabillities. AbilityStageContext extends the base Context by exposing HapModuleInfo and Configuration details specific to the module stage. Meanwhile, ApplicationContext serves as the global hub, allowing deveolpers to monitor ability lifecycles, memory shifts, and system ...
Posted on Fri, 05 Jun 2026 18:08:11 +0000 by puritania