harmony 鸿蒙Updating Widget Content
Updating Widget Content
The ArkTS widget framework provides the updateForm API for widget providers and the requestForm API for widget hosts to proactively trigger widget page refreshes. It also alerts providers to update widgets based on the scheduled information.
In widget UI code, you can use LocalStorageProp to obtain the widget data that requires updating, sent by the provider
API | System Capability | Constraints |
---|---|---|
updateForm | No | 1. Invoked by the widget provider. 2. Allows only the widget provider to update its own widgets. |
requestForm | Yes | 1. Invoked by the widget host. 2. Allows only the widget host to update the widgets added to it. |
Widget provider proactively updating a widget
If there is a need to update widget data, the widget provider, as long as it is running, can proactively update the widget using the updateForm API provided by formProvider.
Widget host proactively requesting a widget update
If changes in system language or color scheme are detected, the widget host, as long as it is running, can proactively request to update the widget using the requestForm API provided by formHost. The widget manager then instructs the widget provider to complete the update.
Widget manager instructing the widget provider to periodically update a widget
Based on the scheduled update information configured by the widget provider, the widget manager determines whether to instruct the provider to update the widget, considering factors such as timing information, widget visibility status, and the number of updates.
The following are the typical use cases of widget updates:
- Interval-based Widget Updates
- Time-specific Widget Updates
- Updating Local and Online Images in the Widget
- Updating Widget Content by State
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Configuring Widget Configuration Files
harmony 鸿蒙Updating Widget Content by Widget Host (for System Applications Only)
harmony 鸿蒙Creating an ArkTS Widget
harmony 鸿蒙Launching the UIAbility of the Widget Provider in the Background Through the call Event
harmony 鸿蒙Overview of ArkTs Widget Page Editing Interaction
harmony 鸿蒙Editing and Updating the Widget Content
harmony 鸿蒙Updating Widget Content Through the message Event
harmony 鸿蒙Widget Event Capability Overview
harmony 鸿蒙Launching the UIAbility of the Widget Provider Through the router Event
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦