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