Hi~ I am Xiao L!The development model of Hongmeng Next is like "fitting Lego" - splitting the application into independent modules, and then "assembly" it into a cross-device experience with distributed capabilities.Today, we will show you three key innovation points to unlock new development ideas~
1. Modular development: Let the application "plug and play" π
Core idea
- Atomic Split: Split the application into independent modules (such as login modules, payment modules)
- Loading on demand: The main module only contains necessary functions, and the secondary module is dynamically downloaded
- Cross-project reuse: A module can be called by multiple applications
Practical Example: Modularization of E-commerce Applications
βββ main_module # main module (home page, search)
β βββ src
βββ user_module # User Center module (can be independently tested)
β βββ src
βββ config.json (declare dependency: network_module)
βββ network_module # network request module (general capability)
βββ src
** Advantages**:
- Teams can develop different modules in parallel (such as group A is used as interface, group B is used as network logic)
- Module hot update: Users can get new features without reinstalling the application
2. ArkUI declarative development: "What you see is code" π
Core features
-
State Driver Interface: Use
@State/@Linkto mark data, and automatically update the view when changes - Responsive layout: A set of codes is adapted to mobile phone/flat tablet/car screen
- Componential packaging: Custom components can be reused (such as general buttons, input boxes)
Code comparison: Login interface development
Traditional imperative (Android)
Button btn = new Button(this);
btn.setText("Login");
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Logical processing
}
});
Hongmeng Declarative (ArkUI)
@Entry
@Component
struct Login {
@State isLoading: boolean = false;
build() {
Button(isLoading? 'Loading...' : 'Login')
.onClick(() => this.isLoading = true)
.loading(isLoading) // Automatically switch loading status
.width('80%')
}
}
Efficiency improvement:
- 50% reduction in code volume+
- Separate interface logic from business logic, more intuitive debugging
3. Distributed development: Let the equipment "team collaboration" π₯
Core abilities
- Cross-device task scheduling
- Mobile phone initiates tasks, automatic relay of flat panel/car machine
import taskManager from '@ohos.distributedTask';
taskManager.transferTask(deviceId, 'editDocument'); // Migrate editing tasks to the tablet
- Equipment capability sharing
- Calling sensors/camerases for other devices
import deviceAbility from '@ohos.deviceAbility';
const camera = deviceAbility.acquire('remote:camera:deviceId'); // Use remote camera
- Distributed Data Storage
- Real-time synchronization of multi-device data
import distributedData from '@ohos.distributedData';
distributedData.subscribe('todoList', (data) => { /* Data change callback */ });
Scenario case: Cross-device meeting record
- Mobile phone: Start the meeting record application and call the local microphone to record
- Tablet: Automatically join collaboration, display text translation in real time (using tablet computing power)
- Smart Wear: After the meeting, the watch vibration reminder will be kept.
Code Key Snippet:
// The main device (mobile phone) initiates collaboration
distributedTask.startCollaboration([deviceId]);
// Receive tasks from the device (tablet)
onTaskReceived(task => {
if (task.type === 'recordMeeting') {
startTranscribing(); // Start text translation
}
});
4. Development efficiency tools: "One-stop" to complete the entire processπ
1. New features of DevEco Studio 4.0
- Real-time preview: After modifying the code, the multi-device emulator refreshes the interface synchronously
- Module dependency analysis: Visually view module call relationships and quickly locate conflicts
- Automated Test: Generate cross-device test cases with one click
2. Low-code development platform
- Applicable scenarios: Quickly build tool applications (such as attendance check-in, approval process)
- Operation Example:
- Drag and drop component generation interface (list, form)
- Configure distributed capabilities (such as "click the button β send data to the car machine")
- Publish to the mobile phone/car application market with one click
5. Future trends: "Evolutionary Blueprint" of the development modelπ
- AI-assisted development
- Automatically generate ArkUI interface (upload design draft β automatic code generation)
Intelligently optimize distributed task allocation (such as dynamic scheduling based on device load)
Zero Code Deployment
The module is automatically adapted to all Hongmeng devices after compilation
Real-time monitoring of application performance in the cloud, automatically triggering hot updates
Atomization Service Development
Single module can be published independently as "universal card"
Cards can be called directly by other applications (such as weather cards embedded in calendar applications)
Summary: The "Three Rules" of the New Development Modelπ
- Module priority: The functions that can be split into modules are absolutely not coupled
- Declarative priority: Use ArkUI to describe "what" rather than "how to do it"
- Distributed Priority: When developing any function, consider "Can it be used across devices?"
Top comments (0)