@ohos.WallpaperExtensionAbility (WallpaperExtensionAbility) (System APIs)
The WallpaperExtensionAbility module provides lifecycle callbacks for wallpaper extension abilities and APIs for listening for wallpaper changes.
NOTE
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.
The APIs of this module can be used only in the stage model.
The APIs provided by this module are system APIs.
Modules to Import
import { WallpaperExtensionAbility } from '@kit.BasicServicesKit';
WallpaperExtensionAbility.onCreate(deprecated)
onCreate(want: object): void
Called to initialize a wallpaper extension ability when it is launched. Multi-thread concurrent calls are not supported.
NOTE
This API is supported since API version 10 and deprecated since API version 23.
System capability: SystemCapability.MiscServices.Wallpaper
System API: This is a system API.
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| want | object | Yes | Want information related to the wallpaper extension ability, including the ability name and bundle name. |
Example
import { WallpaperExtensionAbility } from '@kit.BasicServicesKit';
import { Want } from '@kit.AbilityKit';
class WallpaperExt extends WallpaperExtensionAbility {
onCreate(want: Want): void {
console.info('onCreate, want:' + want.abilityName);
}
}
WallpaperExtensionAbility.onWallpaperChange(deprecated)
onWallpaperChange(wallpaperType: number): void
Called when the wallpaper changes. Multi-thread concurrent calls are not supported.
NOTE
This API is supported since API version 10 and deprecated since API version 23.
System capability: SystemCapability.MiscServices.Wallpaper
System API: This is a system API.
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| wallpaperType | number | Yes | Wallpaper type. 0: home screen wallpaper. 1: lock screen wallpaper. |
Example
import { WallpaperExtensionAbility } from '@kit.BasicServicesKit';
import { wallpaper } from '@kit.BasicServicesKit';
class WallpaperExt extends WallpaperExtensionAbility {
onWallpaperChange(wallpaperType: wallpaper.WallpaperType): void {
console.info('onWallpaperChange, wallpaperType:' + wallpaperType);
}
}
WallpaperExtensionAbility.onDestroy(deprecated)
onDestroy(): void
Called when this wallpaper extension ability is destroyed to clear resources. Multi-thread concurrent calls are not supported.
NOTE
This API is supported since API version 10 and deprecated since API version 23.
System capability: SystemCapability.MiscServices.Wallpaper
System API: This is a system API.
Example
import { WallpaperExtensionAbility } from '@kit.BasicServicesKit';
class WallpaperExt extends WallpaperExtensionAbility {
onDestroy(): void {
console.info('onDestroy');
}
}