1e41f4b71Sopenharmony_ci# @ohos.WallpaperExtensionAbility (WallpaperExtensionAbility) (System APIs) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **WallpaperExtensionAbility** module provides lifecycle callbacks for wallpaper extension abilities and APIs for listening for wallpaper changes. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> 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. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> The APIs of this module can be used only in the stage model. 10e41f4b71Sopenharmony_ci> 11e41f4b71Sopenharmony_ci> The APIs provided by this module are system APIs. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## Modules to Import 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci```ts 16e41f4b71Sopenharmony_ciimport { WallpaperExtensionAbility } from '@kit.BasicServicesKit'; 17e41f4b71Sopenharmony_ci``` 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci## WallpaperExtensionAbility.onCreate 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_cionCreate(want: object): void 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciCalled to initialize a wallpaper extension ability when it is launched. Multi-thread concurrent calls are not supported. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**Parameters** 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 30e41f4b71Sopenharmony_ci| ------ | ----------- | ---- | ------------------------------- | 31e41f4b71Sopenharmony_ci| 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.| 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci**Example** 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci```ts 36e41f4b71Sopenharmony_ciimport { WallpaperExtensionAbility } from '@kit.BasicServicesKit'; 37e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ciclass WallpaperExt extends WallpaperExtensionAbility { 40e41f4b71Sopenharmony_ci onCreate(want: Want): void { 41e41f4b71Sopenharmony_ci console.log('onCreate, want:' + want.abilityName); 42e41f4b71Sopenharmony_ci } 43e41f4b71Sopenharmony_ci} 44e41f4b71Sopenharmony_ci``` 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci## WallpaperExtensionAbility.onWallpaperChange 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_cionWallpaperChange(wallpaperType: number): void 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ciCalled when the wallpaper changes. Multi-thread concurrent calls are not supported. 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci**Parameters** 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 57e41f4b71Sopenharmony_ci| ------ | --------- | --- |----------------------| 58e41f4b71Sopenharmony_ci| wallpaperType | number | Yes | Wallpaper type.<br>**0**: home screen wallpaper.<br>**1**: lock screen wallpaper. | 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci**Example** 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci```ts 63e41f4b71Sopenharmony_ciimport { WallpaperExtensionAbility } from '@kit.BasicServicesKit'; 64e41f4b71Sopenharmony_ciimport { wallpaper } from '@kit.BasicServicesKit'; 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ciclass WallpaperExt extends WallpaperExtensionAbility { 67e41f4b71Sopenharmony_ci onWallpaperChange(wallpaperType: wallpaper.WallpaperType): void { 68e41f4b71Sopenharmony_ci console.log('onWallpaperChange, wallpaperType:' + wallpaperType); 69e41f4b71Sopenharmony_ci } 70e41f4b71Sopenharmony_ci} 71e41f4b71Sopenharmony_ci``` 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci## WallpaperExtensionAbility.onDestroy 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_cionDestroy(): void 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ciCalled when this wallpaper extension ability is destroyed to clear resources. Multi-thread concurrent calls are not supported. 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci**System capability**: SystemCapability.MiscServices.Wallpaper 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci**Example** 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ci```ts 84e41f4b71Sopenharmony_ciimport { WallpaperExtensionAbility } from '@kit.BasicServicesKit'; 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ciclass WallpaperExt extends WallpaperExtensionAbility { 87e41f4b71Sopenharmony_ci onDestroy(): void { 88e41f4b71Sopenharmony_ci console.log('onDestroy'); 89e41f4b71Sopenharmony_ci } 90e41f4b71Sopenharmony_ci} 91e41f4b71Sopenharmony_ci``` 92