1# @ohos.WallpaperExtensionAbility (WallpaperExtensionAbility) 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 '@ohos.WallpaperExtensionAbility'; 17``` 18 19## WallpaperExtensionAbility.onCreate 20 21onCreate(want: object): void 22 23Called to initialize a wallpaper extension ability when it is launched. 24 25**System capability**: SystemCapability.MiscServices.Wallpaper 26 27**Parameters** 28 29| Name| Type | Mandatory| Description | 30| ------ | ----------- | ---- | ------------------------------- | 31| want | [object](js-apis-app-ability-want.md) | Yes | Want information related to the wallpaper extension ability, including the ability name and bundle name.| 32 33**Example** 34 35```ts 36import WallpaperExtensionAbility from '@ohos.WallpaperExtensionAbility'; 37import Want from '@ohos.app.ability.Want'; 38 39class WallpaperExt extends WallpaperExtensionAbility { 40 onCreate(want: Want): void { 41 console.log('onCreate, want:' + want.abilityName); 42 } 43} 44``` 45 46## WallpaperExtensionAbility.onWallpaperChange 47 48onWallpaperChange(wallpaperType: number): void 49 50Called when the wallpaper changes. 51 52**System capability**: SystemCapability.MiscServices.Wallpaper 53 54**Parameters** 55 56| Name| Type | Mandatory| Description | 57| ------ | --------- | --- |----------------------| 58| wallpaperType | number | Yes | Wallpaper type. **0**: home screen wallpaper.<br>**1**: lock screen wallpaper.| 59 60**Example** 61 62```ts 63import WallpaperExtensionAbility from '@ohos.WallpaperExtensionAbility'; 64import wallpaper from '@ohos.wallpaper'; 65 66class WallpaperExt extends WallpaperExtensionAbility { 67 onWallpaperChange(wallpaperType: wallpaper.WallpaperType): void { 68 console.log('onWallpaperChange, wallpaperType:' + wallpaperType); 69 } 70} 71``` 72 73## WallpaperExtensionAbility.onDestroy 74 75onDestroy(): void 76 77Called when this wallpaper extension ability is destroyed to clear resources. 78 79**System capability**: SystemCapability.MiscServices.Wallpaper 80 81**Example** 82 83```ts 84import WallpaperExtensionAbility from '@ohos.WallpaperExtensionAbility'; 85 86class WallpaperExt extends WallpaperExtensionAbility { 87 onDestroy(): void { 88 console.log('onDestroy'); 89 } 90} 91``` 92