Working with Atomic Widget Services in HarmonyOS
In this article, we will learn about Atomic Service Widget. Atomic Services are installation-free (installed automatically by the application framework in the background) and can offer one or more convenient services for users. They are future-oriented user applications provided by HarmonyOS. Atomic Services are developed based on HarmonyOS APIs and can run on 1+8+N devices so that users can conveniently use them in proper scenarios and on proper devices. Different from apps installed in a conventional manner, Atomic Services are lightweight and can be instantly and precisely accessed through more entries.
Introduction
In this article, we will learn about Atomic Service Widget. Atomic Services are installation-free (installed automatically by the application framework in the background) and can offer one or more convenient services for users. They are future-oriented user applications provided by HarmonyOS. Atomic Services are developed based on HarmonyOS APIs and can run on 1+8+N devices so that users can conveniently use them in proper scenarios and on proper devices. Different from apps installed in a conventional manner, Atomic Services are lightweight and can be instantly and precisely accessed through more entries.
An Atomic Service consists of one or more HarmonyOS Ability Packages (HAPs) and each HAP file contains one Feature Ability (FA) or Partical Ability (PA) Each FA or PA can run independently to implement a specific functionality, and one or more functionalities (FAs or PAs) implement a specific convenient service.
Atomic Service Features
- Accessible anywhere
- Instant access
- Cross-device
Development Overview
You need to install DevEcho studio IDE and I assume that you have prior knowledge about the Harmony OS and java.
Hardware Requirements
- A computer (desktop or laptop) running Windows 10.
- A HarmonyOS phone (with the USB cable), which is used for debugging.
Software Requirements
- Java JDK installation package.
- DevEcho studio installed.
Steps:
Step 1: Create HarmonyOS Application.
Step 2: Add following maven repo in project level build.gradle file.
Step 3: Add the following maven repo in app level build.gradle file.
You can also check and verify HarmonyOS configuration here before running app.
Step 4. Generating Key and CSR file.
Before generating certificate, you need to add device UDID for testing in real device. Navigate to Users and permissions.
Generate new key and fill the necessary details and Click Next and verify the password to create key file and CSR file in the specified folder.
Step 4. Configuring project in AppGallery.
Login to AppGallery Connect create and navigate to your project.
Choose the HarmonyOS app services from the left bottom menu
HAP Provision Profile Management. Create
Let’s start coding
Once you create service project, IDE will automatically create EntryCard, MainAbility, widget and other controller files like FormController and FormContrillerManager.
Tips and Tricks
- Add required dependencies without fail
- Add required images in resources > base > media
- Add custom strings in resources > base > element > string.json
- Define supporting devices in config.json file.
- Define actions in config.json
- Configure project in AGC without fail.
- Do not log the sensitive data
- Use respective Log methods to print logs.
Result
Widget service created and if you tap on the widget it will start the specified ability in the device.
Conclusion
In this article, we have learnt about Atomic widget services in HarmonyOS which are installation free and these services are future-oriented user applications provided by HarmonyOS.
Atomic Services are developed based on HarmonyOS APIs and can run on 1+8+N devices, so that users can conveniently use them in proper scenarios and on proper devices.
Thank you so much for reading this article and I hope this article helps you to understand Atomic widget services in HarmonyOS. Please provide your comments in the comment section and like.
Reference