• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.WallpaperExtensionAbility (WallpaperExtensionAbility) (System APIs)
2
3The **WallpaperExtensionAbility** module provides lifecycle callbacks for wallpaper extension abilities and APIs for listening for wallpaper changes.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9> The APIs of this module can be used only in the stage model.
10>
11> The APIs provided by this module are system APIs.
12
13## Modules to Import
14
15```ts
16import { WallpaperExtensionAbility } from '@kit.BasicServicesKit';
17```
18
19## WallpaperExtensionAbility.onCreate
20
21onCreate(want: object): void
22
23Called to initialize a wallpaper extension ability when it is launched. Multi-thread concurrent calls are not supported.
24
25**System capability**: SystemCapability.MiscServices.Wallpaper
26
27**System API**: This is a system API.
28
29**Parameters**
30
31| Name| Type         | Mandatory| Description                            |
32| ------ | ----------- | ---- | ------------------------------- |
33| want   | [object](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | Want information related to the wallpaper extension ability, including the ability name and bundle name.|
34
35**Example**
36
37```ts
38import { WallpaperExtensionAbility } from '@kit.BasicServicesKit';
39import { Want } from '@kit.AbilityKit';
40
41class WallpaperExt extends WallpaperExtensionAbility {
42    onCreate(want: Want): void {
43        console.log('onCreate, want:' + want.abilityName);
44    }
45}
46```
47
48## WallpaperExtensionAbility.onWallpaperChange
49
50onWallpaperChange(wallpaperType: number): void
51
52Called when the wallpaper changes. Multi-thread concurrent calls are not supported.
53
54**System capability**: SystemCapability.MiscServices.Wallpaper
55
56**System API**: This is a system API.
57
58**Parameters**
59
60| Name| Type       | Mandatory| Description                  |
61| ------ | --------- | --- |----------------------|
62| wallpaperType  | number | Yes | Wallpaper type.<br>**0**: home screen wallpaper.<br>**1**: lock screen wallpaper. |
63
64**Example**
65
66```ts
67import { WallpaperExtensionAbility } from '@kit.BasicServicesKit';
68import { wallpaper } from '@kit.BasicServicesKit';
69
70class WallpaperExt extends WallpaperExtensionAbility {
71    onWallpaperChange(wallpaperType: wallpaper.WallpaperType): void {
72        console.log('onWallpaperChange, wallpaperType:' + wallpaperType);
73    }
74}
75```
76
77## WallpaperExtensionAbility.onDestroy
78
79onDestroy(): void
80
81Called when this wallpaper extension ability is destroyed to clear resources. Multi-thread concurrent calls are not supported.
82
83**System capability**: SystemCapability.MiscServices.Wallpaper
84
85**System API**: This is a system API.
86
87**Example**
88
89```ts
90import { WallpaperExtensionAbility } from '@kit.BasicServicesKit';
91
92class WallpaperExt extends WallpaperExtensionAbility {
93    onDestroy(): void {
94        console.log('onDestroy');
95    }
96}
97```
98