Skip to content

Most visited

Recently visited

navigation
Added in API level 7

WallpaperService.Engine

public class WallpaperService.Engine
extends Object

java.lang.Object
   ↳ 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 onCreateEngine() to return your concrete Engine implementation.

Summary

Public constructors

WallpaperService.Engine()

Public methods

int getDesiredMinimumHeight()

Convenience for WallpaperManager.getDesiredMinimumHeight(), returning the height that the system would like this wallpaper to run in.

int getDesiredMinimumWidth()

Convenience for WallpaperManager.getDesiredMinimumWidth(), returning the width that the system would like this wallpaper to run in.

SurfaceHolder getSurfaceHolder()

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

boolean 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.

boolean isVisible()

Return whether the wallpaper is currently visible to the user, this is the last value supplied to onVisibilityChanged(boolean).

void onApplyWindowInsets(WindowInsets insets)

Called with the current insets that are in effect for the wallpaper.

Bundle onCommand(String action, int x, int y, int z, Bundle extras, boolean resultRequested)

Process a command that was sent to the wallpaper with sendWallpaperCommand(IBinder, String, int, int, int, Bundle).

void onCreate(SurfaceHolder surfaceHolder)

Called once to initialize the engine.

void onDesiredSizeChanged(int desiredWidth, int desiredHeight)

Called when an application has changed the desired virtual size of the wallpaper.

void onDestroy()

Called right before the engine is going away.

void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset)

Called to inform you of the wallpaper's offsets changing within its contain, corresponding to the container's call to WallpaperManager.setWallpaperOffsets().

void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height)

Convenience for SurfaceHolder.Callback.surfaceChanged().

void onSurfaceCreated(SurfaceHolder holder)

Convenience for SurfaceHolder.Callback.surfaceCreated().

void onSurfaceDestroyed(SurfaceHolder holder)

Convenience for SurfaceHolder.Callback.surfaceDestroyed().

void onSurfaceRedrawNeeded(SurfaceHolder holder)

Convenience for SurfaceHolder.Callback.surfaceRedrawNeeded().

void onTouchEvent(MotionEvent event)

Called as the user performs touch-screen interaction with the window that is currently showing this wallpaper.

void onVisibilityChanged(boolean visible)

Called to inform you of the wallpaper becoming visible or hidden.

void setOffsetNotificationsEnabled(boolean enabled)

Control whether this wallpaper will receive notifications when the wallpaper has been scrolled.

void setTouchEventsEnabled(boolean enabled)

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

void dump(String prefix, FileDescriptor fd, PrintWriter out, String[] args)

Inherited methods

From class java.lang.Object

Public constructors

WallpaperService.Engine

Added in API level 7
WallpaperService.Engine ()

Public methods

getDesiredMinimumHeight

Added in API level 7
int getDesiredMinimumHeight ()

Convenience for WallpaperManager.getDesiredMinimumHeight(), returning the height that the system would like this wallpaper to run in.

Returns
int

getDesiredMinimumWidth

Added in API level 7
int getDesiredMinimumWidth ()

Convenience for WallpaperManager.getDesiredMinimumWidth(), returning the width that the system would like this wallpaper to run in.

Returns
int

getSurfaceHolder

Added in API level 7
SurfaceHolder getSurfaceHolder ()

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

Returns
SurfaceHolder

isPreview

Added in API level 7
boolean 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.

Returns
boolean

isVisible

Added in API level 7
boolean isVisible ()

Return whether the wallpaper is currently visible to the user, this is the last value supplied to onVisibilityChanged(boolean).

Returns
boolean

onApplyWindowInsets

Added in API level 21
void onApplyWindowInsets (WindowInsets insets)

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).

Parameters
insets WindowInsets: Insets to apply.

onCommand

Added in API level 7
Bundle onCommand (String action, 
                int x, 
                int y, 
                int z, 
                Bundle extras, 
                boolean resultRequested)

Process a command that was sent to the wallpaper with sendWallpaperCommand(IBinder, String, int, int, int, Bundle). The default implementation does nothing, and always returns null as the result.

Parameters
action String: The name of the command to perform. This tells you what to do and how to interpret the rest of the arguments.
x int: Generic integer parameter.
y int: Generic integer parameter.
z int: Generic integer parameter.
extras Bundle: Any additional parameters.
resultRequested boolean: If true, the caller is requesting that a result, appropriate for the command, be returned back.
Returns
Bundle If returning a result, create a Bundle and place the result data in to it. Otherwise return null.

onCreate

Added in API level 7
void onCreate (SurfaceHolder surfaceHolder)

Called once to initialize the engine. After returning, the engine's surface will be created by the framework.

Parameters
surfaceHolder SurfaceHolder

onDesiredSizeChanged

Added in API level 7
void onDesiredSizeChanged (int desiredWidth, 
                int desiredHeight)

Called when an application has changed the desired virtual size of the wallpaper.

Parameters
desiredWidth int
desiredHeight int

onDestroy

Added in API level 7
void onDestroy ()

Called right before the engine is going away. After this the surface will be destroyed and this Engine object is no longer valid.

onOffsetsChanged

Added in API level 7
void onOffsetsChanged (float xOffset, 
                float yOffset, 
                float xOffsetStep, 
                float yOffsetStep, 
                int xPixelOffset, 
                int yPixelOffset)

Called to inform you of the wallpaper's offsets changing within its contain, corresponding to the container's call to WallpaperManager.setWallpaperOffsets().

Parameters
xOffset float
yOffset float
xOffsetStep float
yOffsetStep float
xPixelOffset int
yPixelOffset int

onSurfaceChanged

Added in API level 7
void onSurfaceChanged (SurfaceHolder holder, 
                int format, 
                int width, 
                int height)

Convenience for SurfaceHolder.Callback.surfaceChanged().

Parameters
holder SurfaceHolder
format int
width int
height int

onSurfaceCreated

Added in API level 7
void onSurfaceCreated (SurfaceHolder holder)

Convenience for SurfaceHolder.Callback.surfaceCreated().

Parameters
holder SurfaceHolder

onSurfaceDestroyed

Added in API level 7
void onSurfaceDestroyed (SurfaceHolder holder)

Convenience for SurfaceHolder.Callback.surfaceDestroyed().

Parameters
holder SurfaceHolder

onSurfaceRedrawNeeded

Added in API level 9
void onSurfaceRedrawNeeded (SurfaceHolder holder)

Convenience for SurfaceHolder.Callback.surfaceRedrawNeeded().

Parameters
holder SurfaceHolder

onTouchEvent

Added in API level 7
void onTouchEvent (MotionEvent event)

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.

Parameters
event MotionEvent

onVisibilityChanged

Added in API level 7
void onVisibilityChanged (boolean visible)

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..

Parameters
visible boolean

setOffsetNotificationsEnabled

Added in API level 15
void setOffsetNotificationsEnabled (boolean enabled)

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: whether the wallpaper wants to receive offset notifications

setTouchEventsEnabled

Added in API level 7
void setTouchEventsEnabled (boolean enabled)

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(MotionEvent).

Parameters
enabled boolean

Protected methods

dump

Added in API level 14
void dump (String prefix, 
                FileDescriptor fd, 
                PrintWriter out, 
                String[] args)

Parameters
prefix String
fd FileDescriptor
out PrintWriter
args String
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.