# WallpaperService.Engine

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Engine

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/service/wallpaper/WallpaperService.Engine "View this page in Java")  

```
open class Engine
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                         ||
| ↳ | [android.service.wallpaper.WallpaperService.Engine](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#) |

The actual implementation of a wallpaper. A wallpaper service may have multiple instances running (for example as a real wallpaper and as a preview), each of which is represented by its own Engine instance. You must implement[WallpaperService.onCreateEngine()](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService#onCreateEngine())to return your concrete Engine implementation.

## Summary

|                                                              Public constructors                                                               ||
|---------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Engine](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#Engine())`()` Default constructor |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ||
|------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                                               | [getDesiredMinimumHeight](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#getDesiredMinimumHeight())`()` Convenience for[WallpaperManager.getDesiredMinimumHeight()](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#getDesiredMinimumHeight()), returning the height that the system would like this wallpaper to run in.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| open[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                                               | [getDesiredMinimumWidth](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#getDesiredMinimumWidth())`()` Convenience for[WallpaperManager.getDesiredMinimumWidth()](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#getDesiredMinimumWidth()), returning the width that the system would like this wallpaper to run in.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| open[Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)?                                 | [getDisplayContext](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#getDisplayContext())`()` The[Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)with resources that match the current display the wallpaper is on.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| open[SurfaceHolder](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.html#)!                        | [getSurfaceHolder](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#getSurfaceHolder())`()` Provides access to the surface in which this wallpaper is drawn.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| open[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                                               | [getWallpaperFlags](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#getWallpaperFlags())`()` Returns the current wallpaper flags indicating which screen this Engine is rendering to.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                       | [isPreview](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#isPreview())`()` Returns true if this engine is running in preview mode -- that is, it is being shown to the user before they select it as the actual wallpaper.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                       | [isVisible](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#isVisible())`()` Return whether the wallpaper is currently visible to the user, this is the last value supplied to[onVisibilityChanged(boolean)](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onVisibilityChanged(kotlin.Boolean)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [notifyColorsChanged](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#notifyColorsChanged())`()` Notifies the engine that wallpaper colors changed significantly.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| open[WallpaperDescription](https://developer.android.com/reference/kotlin/android/app/wallpaper/WallpaperDescription.html#)? | [onApplyWallpaper](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onApplyWallpaper(kotlin.Int))`(`which:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when the wallpaper preview rendered by this engine is about to be persisted as a selected wallpaper.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [onApplyWindowInsets](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onApplyWindowInsets(android.view.WindowInsets))`(`insets:` `[WindowInsets](https://developer.android.com/reference/kotlin/android/view/WindowInsets.html#)!`)` Called with the current insets that are in effect for the wallpaper.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| open[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!                                        | [onCommand](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onCommand(kotlin.String,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20android.os.Bundle,%20kotlin.Boolean))`(`action:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `x:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `y:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `z:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `extras:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!`, `resultRequested:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Process a command that was sent to the wallpaper with[WallpaperManager.sendWallpaperCommand](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#sendWallpaperCommand(android.os.IBinder,%20kotlin.String,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20android.os.Bundle)).                                                 |
| open[WallpaperColors](https://developer.android.com/reference/kotlin/android/app/WallpaperColors.html#)?                     | [onComputeColors](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onComputeColors())`()` Called by the system when it needs to know what colors the wallpaper is using.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [onCreate](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onCreate(android.view.SurfaceHolder))`(`surfaceHolder:` `[SurfaceHolder](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.html#)!`)` Called once to initialize the engine.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [onDesiredSizeChanged](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onDesiredSizeChanged(kotlin.Int,%20kotlin.Int))`(`desiredWidth:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `desiredHeight:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when an application has changed the desired virtual size of the wallpaper.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [onDestroy](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onDestroy())`()` Called right before the engine is going away.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [onOffsetsChanged](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onOffsetsChanged(kotlin.Float,%20kotlin.Float,%20kotlin.Float,%20kotlin.Float,%20kotlin.Int,%20kotlin.Int))`(`xOffset:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `yOffset:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `xOffsetStep:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `yOffsetStep:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `xPixelOffset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `yPixelOffset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called to inform you of the wallpaper's offsets changing within its contain, corresponding to the container's call to[WallpaperManager.setWallpaperOffsets()](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#setWallpaperOffsets(android.os.IBinder,%20kotlin.Float,%20kotlin.Float)). |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [onSurfaceChanged](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onSurfaceChanged(android.view.SurfaceHolder,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int))`(`holder:` `[SurfaceHolder](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.html#)!`, `format:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `width:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `height:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Convenience for[SurfaceHolder.Callback.surfaceChanged()](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.Callback.html#surfaceChanged(android.view.SurfaceHolder,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)).                                                                                                                                                                                                                                                                                                        |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [onSurfaceCreated](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onSurfaceCreated(android.view.SurfaceHolder))`(`holder:` `[SurfaceHolder](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.html#)!`)` Convenience for[SurfaceHolder.Callback.surfaceCreated()](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.Callback.html#surfaceCreated(android.view.SurfaceHolder)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [onSurfaceDestroyed](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onSurfaceDestroyed(android.view.SurfaceHolder))`(`holder:` `[SurfaceHolder](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.html#)!`)` Convenience for[SurfaceHolder.Callback.surfaceDestroyed()](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.Callback.html#surfaceDestroyed(android.view.SurfaceHolder)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [onSurfaceRedrawNeeded](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onSurfaceRedrawNeeded(android.view.SurfaceHolder))`(`holder:` `[SurfaceHolder](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.html#)!`)` Convenience for[SurfaceHolder.Callback.surfaceRedrawNeeded()](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.Callback2.html#surfaceRedrawNeeded(android.view.SurfaceHolder)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [onTouchEvent](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onTouchEvent(android.view.MotionEvent))`(`event:` `[MotionEvent](https://developer.android.com/reference/kotlin/android/view/MotionEvent.html#)!`)` Called as the user performs touch-screen interaction with the window that is currently showing this wallpaper.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [onVisibilityChanged](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onVisibilityChanged(kotlin.Boolean))`(`visible:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Called to inform you of the wallpaper becoming visible or hidden.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [onWallpaperFlagsChanged](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onWallpaperFlagsChanged(kotlin.Int))`(`which:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when the current wallpaper flags change.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [onZoomChanged](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onZoomChanged(kotlin.Float))`(`zoom:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`)` Called when the zoom level of the wallpaper changed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [setOffsetNotificationsEnabled](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#setOffsetNotificationsEnabled(kotlin.Boolean))`(`enabled:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Control whether this wallpaper will receive notifications when the wallpaper has been scrolled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                             | [setTouchEventsEnabled](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#setTouchEventsEnabled(kotlin.Boolean))`(`enabled:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Control whether this wallpaper will receive raw touch events from the window manager as the user interacts with the window that is currently displaying the wallpaper.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

|                                                                                                                                                                                                                                                                                                                                                                                Protected methods                                                                                                                                                                                                                                                                                                                                                                                 ||
|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [dump](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#dump(kotlin.String,%20java.io.FileDescriptor,%20java.io.PrintWriter,%20kotlin.Array))`(`prefix:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `fd:` `[FileDescriptor](https://developer.android.com/reference/kotlin/java/io/FileDescriptor.html#)!`, `out:` `[PrintWriter](https://developer.android.com/reference/kotlin/java/io/PrintWriter.html#)!`, `args:` `[Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!>!`)` <br /> |

## Public constructors

### Engine

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Engine()
```

Default constructor

## Public methods

### getDesiredMinimumHeight

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getDesiredMinimumHeight(): Int
```

Convenience for[WallpaperManager.getDesiredMinimumHeight()](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#getDesiredMinimumHeight()), returning the height that the system would like this wallpaper to run in.  

### getDesiredMinimumWidth

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getDesiredMinimumWidth(): Int
```

Convenience for[WallpaperManager.getDesiredMinimumWidth()](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#getDesiredMinimumWidth()), returning the width that the system would like this wallpaper to run in.  

### getDisplayContext

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getDisplayContext(): Context?
```

The[Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)with resources that match the current display the wallpaper is on. For multiple display environment, multiple engines can be created to render on each display, but these displays may have different densities. Use this context to get the corresponding resources for currently display, avoiding the context of the service.

The display context will never be`null`after[Engine.onCreate(SurfaceHolder)](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onCreate(android.view.SurfaceHolder))has been called.

|                                                                                                 Return                                                                                                 ||
|------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
| [Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)? | A[Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)for current display. |

### getSurfaceHolder

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getSurfaceHolder(): SurfaceHolder!
```

Provides access to the surface in which this wallpaper is drawn.  

### getWallpaperFlags

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getWallpaperFlags(): Int
```

Returns the current wallpaper flags indicating which screen this Engine is rendering to.

|                                                                                                                                                                                                          Return                                                                                                                                                                                                          ||
|----------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | Value is either`0`or a combination of[android.app.WallpaperManager#FLAG_SYSTEM](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#FLAG_SYSTEM:kotlin.Int), and[android.app.WallpaperManager#FLAG_LOCK](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#FLAG_LOCK:kotlin.Int) |

### isPreview

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun isPreview(): Boolean
```

Returns true if this engine is running in preview mode -- that is, it is being shown to the user before they select it as the actual wallpaper.  

### isVisible

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun isVisible(): Boolean
```

Return whether the wallpaper is currently visible to the user, this is the last value supplied to[onVisibilityChanged(boolean)](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onVisibilityChanged(kotlin.Boolean)).  

### notifyColorsChanged

Added in[API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun notifyColorsChanged(): Unit
```

Notifies the engine that wallpaper colors changed significantly. This will trigger a[onComputeColors()](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onComputeColors())call.  

### onApplyWallpaper

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onApplyWallpaper(which: Int): WallpaperDescription?
```

Called when the wallpaper preview rendered by this engine is about to be persisted as a selected wallpaper. The returned WallpaperDescription (if any) will be persisted by the system and passed into subsequent calls to[WallpaperService.onCreateEngine(WallpaperDescription)](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService#onCreateEngine(android.app.wallpaper.WallpaperDescription)). This allows the Engine to perform any necessary bookkeeping before a wallpaper being previewed is set on the device, and update the description if necessary.

|                                                                                                                                                                                                                                      Parameters                                                                                                                                                                                                                                       ||
|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `which` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Specifies wallpaper destination: home, lock, or both Value is either`0`or a combination of[android.app.WallpaperManager#FLAG_SYSTEM](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#FLAG_SYSTEM:kotlin.Int), and[android.app.WallpaperManager#FLAG_LOCK](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#FLAG_LOCK:kotlin.Int) |

|                                                                                                 Return                                                                                                  ||
|--------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|
| [WallpaperDescription](https://developer.android.com/reference/kotlin/android/app/wallpaper/WallpaperDescription.html#)? | the description of the applied wallpaper, or`null`if description is unchanged |

### onApplyWindowInsets

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onApplyWindowInsets(insets: WindowInsets!): Unit
```

Called with the current insets that are in effect for the wallpaper. This gives you the part of the overall wallpaper surface that will generally be visible to the user (ignoring position offsets applied to it).  
This method must be called from the main thread of your app.

|                                                         Parameters                                                         ||
|----------|------------------------------------------------------------------------------------------------------------------|
| `insets` | [WindowInsets](https://developer.android.com/reference/kotlin/android/view/WindowInsets.html#)!:Insets to apply. |

### onCommand

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onCommand(
    action: String!, 
    x: Int, 
    y: Int, 
    z: Int, 
    extras: Bundle!, 
    resultRequested: Boolean
): Bundle!
```

Process a command that was sent to the wallpaper with[WallpaperManager.sendWallpaperCommand](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#sendWallpaperCommand(android.os.IBinder,%20kotlin.String,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20android.os.Bundle)). The default implementation does nothing, and always returns null as the result.  
This method must be called from the main thread of your app.

|                                                                                                     Parameters                                                                                                     ||
|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `action`          | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:The name of the command to perform. This tells you what to do and how to interpret the rest of the arguments. |
| `x`               | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Generic integer parameter.                                                                                           |
| `y`               | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Generic integer parameter.                                                                                           |
| `z`               | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Generic integer parameter.                                                                                           |
| `extras`          | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!:Any additional parameters.                                                                                    |
| `resultRequested` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):If true, the caller is requesting that a result, appropriate for the command, be returned back.              |

|                                                                                        Return                                                                                        ||
|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
| [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)! | If returning a result, create a Bundle and place the result data in to it. Otherwise return null. |

### onComputeColors

Added in[API level 27](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onComputeColors(): WallpaperColors?
```

Called by the system when it needs to know what colors the wallpaper is using. You might return null if no color information is available at the moment. In that case you might want to call[notifyColorsChanged()](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#notifyColorsChanged())when color information becomes available.

The simplest way of creating a[android.app.WallpaperColors](https://developer.android.com/reference/kotlin/android/app/WallpaperColors.html#)object is by using[android.app.WallpaperColors#fromBitmap(Bitmap)](https://developer.android.com/reference/kotlin/android/app/WallpaperColors.html#fromBitmap(android.graphics.Bitmap))or[android.app.WallpaperColors#fromDrawable(Drawable)](https://developer.android.com/reference/kotlin/android/app/WallpaperColors.html#fromDrawable(android.graphics.drawable.Drawable)), but you can also specify your main colors by constructing a[android.app.WallpaperColors](https://developer.android.com/reference/kotlin/android/app/WallpaperColors.html#)object manually.  
This method must be called from the main thread of your app.

|                                                         Return                                                          ||
|------------------------------------------------------------------------------------------------------|-------------------|
| [WallpaperColors](https://developer.android.com/reference/kotlin/android/app/WallpaperColors.html#)? | Wallpaper colors. |

### onCreate

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onCreate(surfaceHolder: SurfaceHolder!): Unit
```

Called once to initialize the engine. After returning, the engine's surface will be created by the framework.  
This method must be called from the main thread of your app.  

### onDesiredSizeChanged

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onDesiredSizeChanged(
    desiredWidth: Int, 
    desiredHeight: Int
): Unit
```

Called when an application has changed the desired virtual size of the wallpaper.  
This method must be called from the main thread of your app.  

### onDestroy

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onDestroy(): Unit
```

Called right before the engine is going away. After this the surface will be destroyed and this Engine object is no longer valid.  
This method must be called from the main thread of your app.  

### onOffsetsChanged

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onOffsetsChanged(
    xOffset: Float, 
    yOffset: Float, 
    xOffsetStep: Float, 
    yOffsetStep: Float, 
    xPixelOffset: Int, 
    yPixelOffset: Int
): Unit
```

Called to inform you of the wallpaper's offsets changing within its contain, corresponding to the container's call to[WallpaperManager.setWallpaperOffsets()](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#setWallpaperOffsets(android.os.IBinder,%20kotlin.Float,%20kotlin.Float)).  
This method must be called from the main thread of your app.  

### onSurfaceChanged

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onSurfaceChanged(
    holder: SurfaceHolder!, 
    format: Int, 
    width: Int, 
    height: Int
): Unit
```

Convenience for[SurfaceHolder.Callback.surfaceChanged()](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.Callback.html#surfaceChanged(android.view.SurfaceHolder,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)).  
This method must be called from the main thread of your app.  

### onSurfaceCreated

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onSurfaceCreated(holder: SurfaceHolder!): Unit
```

Convenience for[SurfaceHolder.Callback.surfaceCreated()](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.Callback.html#surfaceCreated(android.view.SurfaceHolder)).  
This method must be called from the main thread of your app.  

### onSurfaceDestroyed

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onSurfaceDestroyed(holder: SurfaceHolder!): Unit
```

Convenience for[SurfaceHolder.Callback.surfaceDestroyed()](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.Callback.html#surfaceDestroyed(android.view.SurfaceHolder)).  
This method must be called from the main thread of your app.  

### onSurfaceRedrawNeeded

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onSurfaceRedrawNeeded(holder: SurfaceHolder!): Unit
```

Convenience for[SurfaceHolder.Callback.surfaceRedrawNeeded()](https://developer.android.com/reference/kotlin/android/view/SurfaceHolder.Callback2.html#surfaceRedrawNeeded(android.view.SurfaceHolder)).  
This method must be called from the main thread of your app.  

### onTouchEvent

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onTouchEvent(event: MotionEvent!): Unit
```

Called as the user performs touch-screen interaction with the window that is currently showing this wallpaper. Note that the events you receive here are driven by the actual application the user is interacting with, so if it is slow you will get fewer move events.  
This method must be called from the main thread of your app.  

### onVisibilityChanged

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onVisibilityChanged(visible: Boolean): Unit
```

Called to inform you of the wallpaper becoming visible or hidden.*It is very important that a wallpaper only use CPU while it is visible.* .  
This method must be called from the main thread of your app.  

### onWallpaperFlagsChanged

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onWallpaperFlagsChanged(which: Int): Unit
```

Called when the current wallpaper flags change.  
This method must be called from the main thread of your app.

|                                                                                                                                                                                                                     Parameters                                                                                                                                                                                                                      ||
|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `which` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The new flag value Value is either`0`or a combination of[android.app.WallpaperManager#FLAG_SYSTEM](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#FLAG_SYSTEM:kotlin.Int), and[android.app.WallpaperManager#FLAG_LOCK](https://developer.android.com/reference/kotlin/android/app/WallpaperManager.html#FLAG_LOCK:kotlin.Int) |

**See Also**

- <https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#getWallpaperFlags()>  

### onZoomChanged

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onZoomChanged(zoom: Float): Unit
```

Called when the zoom level of the wallpaper changed. This method will be called with the initial zoom level when the surface is created.  
This method must be called from the main thread of your app.

|                                                                                                       Parameters                                                                                                        ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `zoom` | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html):the zoom level, between 0 indicating fully zoomed in and 1 indicating fully zoomed out. Value is between 0.0f and 1.0f inclusive |

### setOffsetNotificationsEnabled

Added in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setOffsetNotificationsEnabled(enabled: Boolean): Unit
```

Control whether this wallpaper will receive notifications when the wallpaper has been scrolled. By default, wallpapers will receive notifications, although the default static image wallpapers do not. It is a performance optimization to set this to false.

|                                                                        Parameters                                                                         ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------|
| `enabled` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):whether the wallpaper wants to receive offset notifications |

### setTouchEventsEnabled

Added in[API level 7](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setTouchEventsEnabled(enabled: Boolean): Unit
```

Control whether this wallpaper will receive raw touch events from the window manager as the user interacts with the window that is currently displaying the wallpaper. By default they are turned off. If enabled, the events will be received in[onTouchEvent(android.view.MotionEvent)](https://developer.android.com/reference/kotlin/android/service/wallpaper/WallpaperService.Engine#onTouchEvent(android.view.MotionEvent)).

## Protected methods

### dump

Added in[API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
protected open fun dump(
    prefix: String!, 
    fd: FileDescriptor!, 
    out: PrintWriter!, 
    args: Array<String!>!
): Unit
```