• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3633

entry/12-May-2024-1,222966

screenshots/device/12-May-2024-

.gitignoreD12-May-202456 55

README.mdD12-May-20242 KiB4221

README_zh.mdD12-May-20241.6 KiB4121

build-profile.json5D12-May-20241 KiB4341

hvigorfile.jsD12-May-2024168 21

package.jsonD12-May-2024399 2019

README.md

1# Gallery Widget
2
3### Introduction
4
5This sample demonstrates the display of **Gallery** images in a widget and periodic update of the widget. The display effect is as follows:
6
7![](screenshots/device/gallery.png) ![](screenshots/device/gallery_form.png)
8
9### Concepts
10
11Media library management: You can use **getAllObject** of the media library instance to query the paths of all images in **Gallery**, and use **open** to obtain the file descriptor (FD) of an image in the specified path. This FD will be used as a key parameter for creating a widget.
12
13Widget update: You can use **formProvider.setFormNextRefreshTime** to set the next refresh time (5 minutes at minimum) for a widget. After the specified time elapsed, the **onUpdate** callback is invoked to update the widget.
14
15### Required Permissions
16
17**ohos.permission.MEDIA_LOCATION**, which allows an app to access geographical locations in the user's media file.
18
19**ohos.permission.READ_MEDIA**, which allows an app to read media files from the user's external storage.
20
21**ohos.permission.WRITE_MEDIA**, which allows an app to read media files from and write media files into the user's external storage.
22
23### Usage
24
251. When you start the app for the first time, you must grant the app the permission to access the geographical location information in your media file.
26
272. Touch and hold the app icon to create a widget and add the widget to the home screen. The widget displays images in **Gallery** properly.
28
293. Touch the image displayed on the widget to start the app.
30
31### Constraints
32
331. This sample can only be run on standard-system devices.
34
352. This sample is based on the stage model, which is supported from API version 9.
36
373. DevEco Studio 3.0 Beta3 (Build version: 3.0.0.992, built on July 6, 2022) must be used.
38
394. Before creating a widget, ensure that there are images in **Gallery**. Otherwise, the widget will not be updated.
40
415. The update takes place 5 minutes after the widget is created when the device screen is on.
42

README_zh.md

1# 图库卡片
2
3### 简介
4
5本示例是模拟图库卡片,实现对图库中的照片在卡片中显示,定时刷新卡片内容等功能。实现效果如下:
6
7![](screenshots/device/gallery.png) ![](screenshots/device/gallery_form.png)
8
9### 相关概念
10
11媒体库管理:通过媒体库 getAllObject查询图库中所有的图片路径,通过open获取指定路径的图片fd,作为创建卡片的关键参数。
12
13卡片数据更新:卡片数据更新可以调用formProvider中的setFormNextRefreshTime去设定卡片更新时间,最短时间为5分钟。在设定的时间结束后触发onUpdate回调更新卡片。
14
15### 相关权限
16
17允许应用访问用户媒体文件中的地理位置信息:ohos.permission.MEDIA_LOCATION
18
19允许应用读取用户外部存储中的媒体文件信息:ohos.permission.READ_MEDIA
20
21允许应用读写用户外部存储中的媒体文件信息:ohos.permission.WRITE_MEDIA
22
23### 使用说明
24
251.首次打开应用,需要赋允许应用访问用户媒体文件中的地理位置信息权限。
26
272.长按应用图标创建卡片,将卡片添加至桌面,卡片正常显示图库照片。
28
293.点击卡片显示的图片可以拉起本应用。
30
31### 约束与限制
32
331.本示例仅支持在标准系统上运行。
34
352.本示例为Stage模型,从API version 9开始支持。
36
373.本示例需要使用DevEco Studio 3.0 Beta3 (Build Version: 3.0.0.992, built on July 6, 2022)才可编译运行。
38
394.在创建卡片前确保系统图库中有图片,否则卡片不更新。
40
415.卡片内容更新为卡片创建5分钟后,且需要设备是亮屏的,否则卡片不更新。