• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Wallpaper
2
3
4> **NOTE**
5>
6> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
7
8
9## Modules to Import
10
11
12```
13import wallpaper from '@ohos.wallpaper';
14```
15
16
17## WallpaperType
18
19Defines the wallpaper type.
20
21**System capability**: SystemCapability.MiscServices.Wallpaper
22
23| Name | Description |
24| -------- | -------- |
25| WALLPAPER_LOCKSCREEN | Lock screen wallpaper. |
26| WALLPAPER_SYSTEM | Home screen wallpaper. |
27
28
29## wallpaper.getColors
30
31getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<RgbaColor>>): void
32
33Obtains the main color information of the wallpaper of the specified type. This API uses an asynchronous callback to return the result.
34
35**System capability**: SystemCapability.MiscServices.Wallpaper
36
37**Parameters**
38| Name | Type | Mandatory | Description |
39| -------- | -------- | -------- | -------- |
40| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
41| callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | Yes | Callback used to return the main color information of the wallpaper. |
42
43**Example**
44
45  ```js
46  wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
47      if (error) {
48          console.error(`failed to getColors because: ` + JSON.stringify(error));
49          return;
50      }
51      console.log(`success to getColors.`);
52  });
53  ```
54
55
56## wallpaper.getColors
57
58getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>>
59
60Obtains the main color information of the wallpaper of the specified type. This API uses a promise to return the result.
61
62**System capability**: SystemCapability.MiscServices.Wallpaper
63
64**Parameters**
65
66| Name | Type | Mandatory | Description |
67| -------- | -------- | -------- | -------- |
68| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
69
70**Return value**
71
72| Type | Description |
73| -------- | -------- |
74| Promise<Array<[RgbaColor](#rgbacolor)>> | Promise used to return the main color information of the wallpaper. |
75
76**Example**
77
78  ```js
79  wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
80      console.log(`success to getColors.`);
81  }).catch((error) => {
82      console.error(`failed to getColors because: ` + JSON.stringify(error));
83  });
84  ```
85
86
87## wallpaper.getId
88
89getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void
90
91Obtains the ID of the wallpaper of the specified type. This API uses an asynchronous callback to return the result.
92
93**System capability**: SystemCapability.MiscServices.Wallpaper
94
95**Parameters**
96
97| Name | Type | Mandatory | Description |
98| -------- | -------- | -------- | -------- |
99| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
100| callback | AsyncCallback<number> | Yes | Callback used to return the wallpaper ID. If the wallpaper of the specified type is configured, a number greater than or equal to **0** is returned. Otherwise, **-1** is returned. The value ranges from -1 to 2^31-1. |
101
102**Example**
103
104  ```js
105  wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
106      if (error) {
107          console.error(`failed to getId because: ` + JSON.stringify(error));
108          return;
109      }
110      console.log(`success to getId: ` + JSON.stringify(data));
111  });
112  ```
113
114
115## wallpaper.getId
116
117getId(wallpaperType: WallpaperType): Promise<number>
118
119Obtains the ID of the wallpaper of the specified type. This API uses a promise to return the result.
120
121**System capability**: SystemCapability.MiscServices.Wallpaper
122
123
124**Parameters**
125
126| Name | Type | Mandatory | Description |
127| -------- | -------- | -------- | -------- |
128| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
129
130**Return value**
131
132| Type | Description |
133| -------- | -------- |
134| Promise<number> | Promise used to return the wallpaper ID. If this type of wallpaper is configured, a number greater than or equal to **0** is returned. Otherwise, **-1** is returned. The value ranges from -1 to 2^31-1. |
135
136**Example**
137
138  ```js
139  wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
140      console.log(`success to getId: ` + JSON.stringify(data));
141  }).catch((error) => {
142      console.error(`failed to getId because: ` + JSON.stringify(error));
143  });
144  ```
145
146
147## wallpaper.getMinHeight
148
149getMinHeight(callback: AsyncCallback<number>): void
150
151Obtains the minimum height of this wallpaper. This API uses an asynchronous callback to return the result.
152
153**System capability**: SystemCapability.MiscServices.Wallpaper
154
155**Parameters**
156
157| Name | Type | Mandatory | Description |
158| -------- | -------- | -------- | -------- |
159| callback | AsyncCallback<number> | Yes | Callback used to return the minimum wallpaper height, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default height should be used instead. |
160
161**Example**
162
163  ```js
164  wallpaper.getMinHeight((error, data) => {
165      if (error) {
166          console.error(`failed to getMinHeight because: ` + JSON.stringify(error));
167          return;
168      }
169      console.log(`success to getMinHeight: ` + JSON.stringify(data));
170  });
171  ```
172
173
174## wallpaper.getMinHeight
175
176getMinHeight(): Promise<number>
177
178Obtains the minimum height of this wallpaper. This API uses a promise to return the result.
179
180**System capability**: SystemCapability.MiscServices.Wallpaper
181
182
183**Return value**
184
185| Type | Description |
186| -------- | -------- |
187| Promise<number> | Promise used to return the minimum wallpaper height, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default height should be used instead. |
188
189**Example**
190
191  ```js
192  wallpaper.getMinHeight().then((data) => {
193      console.log(`success to getMinHeight: ` + JSON.stringify(data));
194  }).catch((error) => {
195      console.error(`failed to getMinHeight because: ` + JSON.stringify(error));
196  });
197  ```
198
199
200## wallpaper.getMinWidth
201
202getMinWidth(callback: AsyncCallback<number>): void
203
204Obtains the minimum width of this wallpaper. This API uses an asynchronous callback to return the result.
205
206**System capability**: SystemCapability.MiscServices.Wallpaper
207
208**Parameters**
209
210| Name | Type | Mandatory | Description |
211| -------- | -------- | -------- | -------- |
212| callback | AsyncCallback<number> | Yes | Callback used to return the minimum wallpaper width, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default width should be used instead. |
213
214**Example**
215
216  ```js
217  wallpaper.getMinWidth((error, data) => {
218      if (error) {
219          console.error(`failed to getMinWidth because: ` + JSON.stringify(error));
220          return;
221      }
222      console.log(`success to getMinWidth: ` + JSON.stringify(data));
223  });
224  ```
225
226
227## wallpaper.getMinWidth
228
229getMinWidth(): Promise<number>
230
231Obtains the minimum width of this wallpaper. This API uses a promise to return the result.
232
233**System capability**: SystemCapability.MiscServices.Wallpaper
234
235**Return value**
236
237| Type | Description |
238| -------- | -------- |
239| Promise<number> | Promised used to return the minimum wallpaper width, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default width should be used instead. |
240
241**Example**
242
243  ```js
244  wallpaper.getMinWidth().then((data) => {
245      console.log(`success to getMinWidth: ` + JSON.stringify(data));
246  }).catch((error) => {
247      console.error(`failed to getMinWidth because: ` + JSON.stringify(error));
248  });
249  ```
250
251
252## wallpaper.isChangePermitted
253
254isChangePermitted(callback: AsyncCallback<boolean>): void
255
256Checks whether to allow the application to change the wallpaper for the current user. This API uses an asynchronous callback to return the result.
257
258**System capability**: SystemCapability.MiscServices.Wallpaper
259
260**Parameters**
261
262| Name | Type | Mandatory | Description |
263| -------- | -------- | -------- | -------- |
264| callback | AsyncCallback<boolean> | Yes | Returns **true** if the application is allowed to change the wallpaper for the current user; returns **false** otherwise. |
265
266**Example**
267
268  ```js
269  wallpaper.isChangePermitted((error, data) => {
270      if (error) {
271          console.error(`failed to isChangePermitted because: ` + JSON.stringify(error));
272          return;
273      }
274      console.log(`success to isChangePermitted: ` + JSON.stringify(data));
275  });
276  ```
277
278
279## wallpaper.isChangePermitted
280
281isChangePermitted(): Promise<boolean>
282
283Checks whether to allow the application to change the wallpaper for the current user. This API uses a promise to return the result.
284
285**System capability**: SystemCapability.MiscServices.Wallpaper
286
287**Return value**
288
289| Type | Description |
290| -------- | -------- |
291| Promise<boolean> | Returns **true** if the application is allowed to change the wallpaper for the current user; returns **false** otherwise. |
292
293**Example**
294
295  ```js
296  wallpaper.isChangePermitted().then((data) => {
297      console.log(`success to isChangePermitted: ` + JSON.stringify(data));
298  }).catch((error) => {
299      console.error(`failed to isChangePermitted because: ` + JSON.stringify(error));
300  });
301  ```
302
303
304## wallpaper.isOperationAllowed
305
306isOperationAllowed(callback: AsyncCallback<boolean>): void
307
308Checks whether the user is allowed to set wallpapers. This API uses an asynchronous callback to return the result.
309
310**System capability**: SystemCapability.MiscServices.Wallpaper
311
312**Parameters**
313
314| Name | Type | Mandatory | Description |
315| -------- | -------- | -------- | -------- |
316| callback | AsyncCallback<boolean> | Yes | Returns **true** if the user is allowed to set wallpapers; returns **false** otherwise. |
317
318**Example**
319
320  ```js
321  wallpaper.isOperationAllowed((error, data) => {
322      if (error) {
323          console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error));
324          return;
325      }
326      console.log(`success to isOperationAllowed: ` + JSON.stringify(data));
327  });
328  ```
329
330
331## wallpaper.isOperationAllowed
332
333isOperationAllowed(): Promise<boolean>
334
335Checks whether the user is allowed to set wallpapers. This API uses a promise to return the result.
336
337**System capability**: SystemCapability.MiscServices.Wallpaper
338
339**Return value**
340
341| Type | Description |
342| -------- | -------- |
343| Promise<boolean> | Returns **true** if the user is allowed to set wallpapers; returns **false** otherwise. |
344
345**Example**
346
347  ```js
348  wallpaper.isOperationAllowed().then((data) => {
349      console.log(`success to isOperationAllowed: ` + JSON.stringify(data));
350  }).catch((error) => {
351      console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error));
352  });
353  ```
354
355
356## wallpaper.reset
357
358reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void
359
360Resets the wallpaper of the specified type to the default wallpaper. This API uses an asynchronous callback to return the result.
361
362**Required permissions**: ohos.permission.SET_WALLPAPER
363
364**System capability**: SystemCapability.MiscServices.Wallpaper
365
366**Parameters**
367
368| Name | Type | Mandatory | Description |
369| -------- | -------- | -------- | -------- |
370| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
371| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned. |
372
373**Example**
374
375  ```js
376  wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
377      if (error) {
378          console.error(`failed to reset because: ` + JSON.stringify(error));
379          return;
380      }
381      console.log(`success to reset.`);
382  });
383  ```
384
385
386## wallpaper.reset
387
388reset(wallpaperType: WallpaperType): Promise<void>
389
390Resets the wallpaper of the specified type to the default wallpaper. This API uses a promise to return the result.
391
392**Required permissions**: ohos.permission.SET_WALLPAPER
393
394**System capability**: SystemCapability.MiscServices.Wallpaper
395
396**Parameters**
397
398| Name | Type | Mandatory | Description |
399| -------- | -------- | -------- | -------- |
400| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
401
402**Return value**
403
404| Type | Description |
405| -------- | -------- |
406| Promise<void> | Promise used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned. |
407
408**Example**
409
410  ```js
411  wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
412      console.log(`success to reset.`);
413  }).catch((error) => {
414      console.error(`failed to reset because: ` + JSON.stringify(error));
415  });
416  ```
417
418
419## wallpaper.setWallpaper
420
421setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void
422
423Sets a specified source as the wallpaper of a specified type. This API uses an asynchronous callback to return the result.
424
425**Required permissions**: ohos.permission.SET_WALLPAPER
426
427**System capability**: SystemCapability.MiscServices.Wallpaper
428
429**Parameters**
430
431| Name | Type | Mandatory | Description |
432| -------- | -------- | -------- | -------- |
433| source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | URI of a JPEG or PNG file, or bitmap of a PNG file. |
434| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
435| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. |
436
437**Example**
438
439  ```js
440  // The source type is string.
441  let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
442  wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
443      if (error) {
444          console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
445          return;
446      }
447      console.log(`success to setWallpaper.`);
448  });
449
450  // The source type is image.PixelMap.
451  import image from '@ohos.multimedia.image';
452  let imageSource = image.createImageSource("file://" + wallpaperPath);
453  let opts = {
454      "desiredSize": {
455          "height": 3648,
456          "width": 2736
457      }
458  };
459  imageSource.createPixelMap(opts).then((pixelMap) => {
460      wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
461          if (error) {
462              console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
463              return;
464          }
465          console.log(`success to setWallpaper.`);
466      });
467  }).catch((error) => {
468      console.error(`failed to createPixelMap because: ` + JSON.stringify(error));
469  });
470  ```
471
472
473## wallpaper.setWallpaper
474
475setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void>
476
477Sets a specified source as the wallpaper of a specified type. This API uses a promise to return the result.
478
479**Required permissions**: ohos.permission.SET_WALLPAPER
480
481**System capability**: SystemCapability.MiscServices.Wallpaper
482
483**Parameters**
484
485| Name | Type | Mandatory | Description |
486| -------- | -------- | -------- | -------- |
487| source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | URI path of the JPEG or PNG file, or bitmap of the PNG file. |
488| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
489
490**Return value**
491
492| Type | Description |
493| -------- | -------- |
494| Promise<void> | Promise used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. |
495
496**Example**
497
498  ```js
499  // The source type is string.
500  let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
501  wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
502      console.log(`success to setWallpaper.`);
503  }).catch((error) => {
504      console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
505  });
506
507  // The source type is image.PixelMap.
508  import image from '@ohos.multimedia.image';
509  let imageSource = image.createImageSource("file://" + wallpaperPath);
510  let opts = {
511      "desiredSize": {
512          "height": 3648,
513          "width": 2736
514      }
515  };
516  imageSource.createPixelMap(opts).then((pixelMap) => {
517      wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
518          console.log(`success to setWallpaper.`);
519      }).catch((error) => {
520          console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
521      });
522  }).catch((error) => {
523      console.error(`failed to createPixelMap because: ` + JSON.stringify(error));
524  });
525  ```
526
527## wallpaper.getFile<sup>8+</sup>
528
529getFile(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): void
530
531Obtains the wallpaper of the specified type. This API uses an asynchronous callback to return the result.
532
533**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE
534
535**System capability**: SystemCapability.MiscServices.Wallpaper
536
537**Parameters**
538
539| Name | Type | Mandatory | Description |
540| -------- | -------- | -------- | -------- |
541| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
542| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. If the operation is successful, the file descriptor ID to the wallpaper is returned. Otherwise, error information is returned. |
543
544**Example**
545
546  ```js
547  wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
548      if (error) {
549          console.error(`failed to getFile because: ` + JSON.stringify(error));
550          return;
551      }
552      console.log(`success to getFile: ` + JSON.stringify(data));
553  });
554  ```
555
556## wallpaper.getFile<sup>8+</sup>
557
558getFile(wallpaperType: WallpaperType): Promise&lt;number&gt;
559
560Obtains the wallpaper of the specified type. This API uses a promise to return the result.
561
562**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE
563
564**System capability**: SystemCapability.MiscServices.Wallpaper
565
566**Parameters**
567
568| Name | Type | Mandatory | Description |
569| -------- | -------- | -------- | -------- |
570| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
571
572**Return value**
573
574| Type | Description |
575| -------- | -------- |
576| Promise&lt;number&gt; | Promise used to return the result. If the operation is successful, the file descriptor ID to the wallpaper is returned. Otherwise, error information is returned. |
577
578**Example**
579
580  ```js
581  wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
582      console.log(`success to getFile: ` + JSON.stringify(data));
583  }).catch((error) => {
584      console.error(`failed to getFile because: ` + JSON.stringify(error));
585  });
586  ```
587
588
589## wallpaper.getPixelMap
590
591getPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback&lt;image.PixelMap&gt;): void;
592
593Obtains the pixel image for the wallpaper of the specified type. This API uses an asynchronous callback to return the result.
594
595**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE
596
597**System capability**: SystemCapability.MiscServices.Wallpaper
598
599**Parameters**
600
601| Name| Type| Mandatory| Description|
602| -------- | -------- | -------- | -------- |
603| wallpaperType | [WallpaperType](#wallpapertype) | Yes| Wallpaper type.|
604| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned.|
605
606**Example**
607
608  ```js
609  wallpaper.getPixelMap(wallpaper.WallpaperType.WALLPAPER_SYSTEM, function (err, data) {
610      console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem err : ' + JSON.stringify(err));
611      console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem data : ' + JSON.stringify(data));
612  });
613  ```
614
615
616## wallpaper.getPixelMap
617
618getPixelMap(wallpaperType: WallpaperType): Promise&lt;image.PixelMap&gt;
619
620Obtains the pixel image for the wallpaper of the specified type. This API uses a promise to return the result.
621
622**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE
623
624**System capability**: SystemCapability.MiscServices.Wallpaper
625
626**Parameters**
627
628| Name| Type| Mandatory| Description|
629| -------- | -------- | -------- | -------- |
630| wallpaperType | [WallpaperType](#wallpapertype) | Yes| Wallpaper type.|
631
632**Return value**
633
634| Type| Description|
635| -------- | -------- |
636| Promise&lt;void&gt; | Promise used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned.|
637
638**Example**
639
640  ```js
641  wallpaper.getPixelMap(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
642      console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + data);
643      console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + JSON.stringify(data));
644  }).catch((err) => {
645      console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + err);
646      console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + JSON.stringify(err));
647  });
648  ```
649
650
651## wallpaper.on('colorChange')
652
653on(type: 'colorChange', callback: (colors: Array&lt;RgbaColor&gt;, wallpaperType: WallpaperType) =&gt; void): void
654
655Subscribes to the wallpaper color change event.
656
657**System capability**: SystemCapability.MiscServices.Wallpaper
658
659**Parameters**
660
661| Name | Type | Mandatory | Description |
662| -------- | -------- | -------- | -------- |
663| type | string | Yes | Type of the event to subscribe to. The value **colorChange** indicates subscribing to the wallpaper color change event. |
664| callback | function | Yes | Callback triggered when the wallpaper color changes. The wallpaper type and main colors are returned.<br>- colors<br>  Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).<br>- wallpaperType<br>  Wallpaper type. |
665
666**Example**
667
668  ```js
669  let listener = (colors, wallpaperType) => {
670      console.log(`wallpaper color changed.`);
671  };
672  wallpaper.on('colorChange', listener);
673  ```
674
675
676## wallpaper.off('colorChange')
677
678off(type: 'colorChange', callback?: (colors: Array&lt;RgbaColor&gt;, wallpaperType: WallpaperType) =&gt; void): void
679
680Unsubscribes from the wallpaper color change event.
681
682**System capability**: SystemCapability.MiscServices.Wallpaper
683
684**Parameters**
685
686| Name | Type | Mandatory | Description |
687| -------- | -------- | -------- | -------- |
688| type | string | Yes | Type of the event to unsubscribe from. The value **colorChange** indicates unsubscribing from the wallpaper color change event. |
689| callback | function | No |   Callback for the wallpaper color change event. If this parameter is not specified, all callbacks corresponding to the wallpaper color change event are invoked.<br>- colors<br>  Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).<br>- wallpaperType<br>  Wallpaper type. |
690
691**Example**
692
693  ```js
694  let listener = (colors, wallpaperType) => {
695      console.log(`wallpaper color changed.`);
696  };
697  wallpaper.on('colorChange', listener);
698  // Unsubscribe from the listener.
699  wallpaper.off('colorChange', listener);
700  // Unsubscribe from all subscriptions of the colorChange type.
701  wallpaper.off('colorChange');
702  ```
703
704
705## RgbaColor
706
707**System capability**: SystemCapability.MiscServices.Wallpaper
708
709| Name | Type | Readable | Writable | Description |
710| -------- | -------- | -------- | -------- | -------- |
711| red | number | Yes | Yes | Red color. The value ranges from 0 to 255. |
712| green | number | Yes | Yes | Green color. The value ranges from 0 to 255. |
713| blue | number | Yes | Yes | Blue color. The value ranges from 0 to 255. |
714| alpha | number | Yes | Yes | Alpha value. The value ranges from 0 to 255. |
715