WallpaperService


public abstract class WallpaperService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.service.wallpaper.WallpaperService


A wallpaper service is responsible for showing a live wallpaper behind applications that would like to sit on top of it. This service object itself does very little -- its only purpose is to generate instances of Engine as needed. Implementing a wallpaper thus involves subclassing from this, subclassing an Engine implementation, and implementing onCreateEngine() to return a new instance of your engine.

Summary

Nested classes

class WallpaperService.Engine

The actual implementation of a wallpaper. 

Constants

String SERVICE_INTERFACE

The Intent that must be declared as handled by the service.

String SERVICE_META_DATA

Name under which a WallpaperService component publishes information about itself.

Inherited constants

Public constructors

WallpaperService()

Public methods

final IBinder onBind(Intent intent)

Implement to return the implementation of the internal accessibility service interface.

void onCreate()

Called by the system when the service is first created.

abstract WallpaperService.Engine onCreateEngine()

Must be implemented to return a new instance of the wallpaper's engine.

void onDestroy()

Called by the system to notify a Service that it is no longer used and is being removed.

Protected methods

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

Print the Service's state into the given stream.

Inherited methods

Constants

SERVICE_INTERFACE

Added in API level 7
public static final String SERVICE_INTERFACE

The Intent that must be declared as handled by the service. To be supported, the service must also require the Manifest.permission.BIND_WALLPAPER permission so that other applications can not abuse it.

Constant Value: "android.service.wallpaper.WallpaperService"

SERVICE_META_DATA

Added in API level 7
public static final String SERVICE_META_DATA

Name under which a WallpaperService component publishes information about itself. This meta-data must reference an XML resource containing a <wallpaper> tag.

Constant Value: "android.service.wallpaper"

Public constructors

WallpaperService

public WallpaperService ()

Public methods

onBind

Added in API level 7
public final IBinder onBind (Intent intent)

Implement to return the implementation of the internal accessibility service interface. Subclasses should not override.

Parameters
intent Intent: The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.

Returns
IBinder Return an IBinder through which clients can call on to the service.

onCreate

Added in API level 7
public void onCreate ()

Called by the system when the service is first created. Do not call this method directly.

onCreateEngine

Added in API level 7
public abstract WallpaperService.Engine onCreateEngine ()

Must be implemented to return a new instance of the wallpaper's engine. Note that multiple instances may be active at the same time, such as when the wallpaper is currently set as the active wallpaper and the user is in the wallpaper picker viewing a preview of it as well.
This method must be called from the main thread of your app.

Returns
WallpaperService.Engine

onDestroy

Added in API level 7
public void onDestroy ()

Called by the system to notify a Service that it is no longer used and is being removed. The service should clean up any resources it holds (threads, registered receivers, etc) at this point. Upon return, there will be no more calls in to this Service object and it is effectively dead. Do not call this method directly.

Protected methods

dump

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

Print the Service's state into the given stream. This gets invoked if you run "adb shell dumpsys activity service <yourservicename>" (note that for this command to work, the service must be running, and you must specify a fully-qualified service name). This is distinct from "dumpsys <servicename>", which only works for named system services and which invokes the IBinder#dump method on the IBinder interface registered with ServiceManager.

Parameters
fd FileDescriptor: The raw file descriptor that the dump is being sent to.

out PrintWriter: The PrintWriter to which you should dump your state. This will be closed for you after you return.

args String: additional arguments to the dump request.