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

Implementing Media Session (Provider) with HarmonyOS

Overview This sample demonstrates the media session provider functionality using the @ohos.multimedia.avsession API. It enables custom data exchange between a media provider and a media controller. Note: This sample only shows the provider side. For the complete custom interaction feature, use both the provider and controller samples together. ...

Posted on Tue, 19 May 2026 01:48:08 +0000 by ManicMax

Essential HarmonyOS Utilities for Data Persistence and Media Selection

Data Persistence Management To handle lightweight data storage efficiently, we can encapsulate the dataPreferences API into a reusable utility class. This abstraction simplifies the process of reading and writing key-value pairs, such as user settings or session tokens. import preferences from '@ohos.data.preferences'; import common from '@oho ...

Posted on Mon, 18 May 2026 12:29:23 +0000 by PastorHank

Implementing UIAbility Navigation in HarmonyOS Applications

Obtaining UIAbility Context In HarmonyOS development, you can retrieve the current ability's context directly within EntryAbility, or obtain the UIAbility instance information from any Page component. Configuring Want Parameters The Want object contains several configuration parameters. The two essential parameters are: bundleName: The target ...

Posted on Mon, 18 May 2026 09:50:53 +0000 by *Lynette

Handling Mouse and Keyboard Interactions in HarmonyOS ArkUI

HarmonyOS ArkUI provides a structured event system for capturing peripheral input. Effective UI development requires precise management of pointer tracking, visual feedback, and hardware keyboard interception. Pointer Hover Detection The onHover modifier monitors when a pointing device enters or exits a component's bounding box. It supplies a b ...

Posted on Sun, 17 May 2026 05:58:08 +0000 by spirp

Building an Audio Recorder and Player Application with HarmonyOS

HarmonyOS provides comprehensive multimedia capabilities for capturing and reproducing audio content through the AudioRecorder and AudioPlayer modules. This implementation demonstrates a complete voice recording application that handles audio capture, file persistence, media library management, and playback controls. Core Concepts The AudioReco ...

Posted on Sat, 09 May 2026 08:23:49 +0000 by PhillNeedsHelp

Implementing Worker Threads in HarmonyOS ArkTS

Worker Thread InitializationImport the worker module and instantiate a thread. For API version 9 and later, utilize ThreadWorker. Earlier versions rely on the deprecated Worker class.import worker from '@ohos.worker'; // API 9+ instantiation const backgroundTask: worker.ThreadWorker = new worker.ThreadWorker('entry/ets/workers/TaskProcessor.et ...

Posted on Thu, 07 May 2026 23:03:35 +0000 by freewholly