WallpaperManager

Provides access to the system wallpaper. With WallpaperManager, you can
get the current wallpaper, get the desired dimensions for the wallpaper, set
the wallpaper, and more. Get an instance of WallpaperManager with
getInstance().

Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.

Constants

ACTION_CHANGE_LIVE_WALLPAPER

Directly launch live wallpaper preview, allowing the user to immediately
confirm to switch to a specific live wallpaper. You must specify
EXTRA_LIVE_WALLPAPER_COMPONENT with the ComponentName of
a live wallpaper component that is to be shown.

Public methods

clear

Remove one or more currently set wallpapers, reverting to the system default
display for each one. If FLAG_SYSTEM is set in the which
parameter, the intent ACTION_WALLPAPER_CHANGED will be broadcast
upon success.

clearWallpaperOffsets

Clear the offsets previously associated with this window through
setWallpaperOffsets(IBinder, float, float). This reverts
the window to its default state, where it does not cause the wallpaper
to scroll from whatever its last offsets were.

forgetLoadedWallpaper

Remove all internal references to the last loaded wallpaper. Useful
for apps that want to reduce memory usage when they only temporarily
need to have the wallpaper. After calling, the next request for the
wallpaper will require reloading it again from disk.

getCropAndSetWallpaperIntent

Gets an Intent that will launch an activity that crops the given
image and sets the device's wallpaper. If there is a default HOME activity
that supports cropping wallpapers, it will be preferred as the default.
Use this method instead of directly creating a ACTION_CROP_AND_SET_WALLPAPER
intent.

Parameters

imageUri

Uri:
The image URI that will be set in the intent. The must be a content
URI and its provider must resolve its type to "image/*"

getDesiredMinimumHeight

Returns the desired minimum height for the wallpaper. Callers of
setBitmap(android.graphics.Bitmap) or
setStream(java.io.InputStream) should check this value
beforehand to make sure the supplied wallpaper respects the desired
minimum height.
If the returned value is <= 0, the caller should use the height of
the default display instead.

Returns

int

The desired minimum height for the wallpaper. This value should
be honored by applications that set the wallpaper but it is not
mandatory.

getDesiredMinimumWidth

Returns the desired minimum width for the wallpaper. Callers of
setBitmap(android.graphics.Bitmap) or
setStream(java.io.InputStream) should check this value
beforehand to make sure the supplied wallpaper respects the desired
minimum width.
If the returned value is <= 0, the caller should use the width of
the default display instead.

Returns

int

The desired minimum width for the wallpaper. This value should
be honored by applications that set the wallpaper but it is not
mandatory.

getDrawable

Retrieve the current system wallpaper; if
no wallpaper is set, the system built-in static wallpaper is returned.
This is returned as an
abstract Drawable that you can install in a View to display whatever
wallpaper the user has currently set.

This method can return null if there is no system wallpaper available, if
wallpapers are not supported in the current user, or if the calling app is not
permitted to access the system wallpaper.

getFastDrawable

Like getDrawable(), but the returned Drawable has a number
of limitations to reduce its overhead as much as possible. It will
never scale the wallpaper (only centering it if the requested bounds
do match the bitmap bounds, which should not be typical), doesn't
allow setting an alpha, color filter, or other attributes, etc. The
bounds of the returned drawable will be initialized to the same bounds
as the wallpaper, so normally you will not need to touch it. The
drawable also assumes that it will be used in a context running in
the same density as the screen (not in density compatibility mode).

isSetWallpaperAllowed

Returns whether the calling package is allowed to set the wallpaper for the calling user.
If this function returns false, any attempts to change the wallpaper will have
no effect. Always returns true for device owner and profile owner.

isWallpaperSupported

Returns whether wallpapers are supported for the calling user. If this function returns
false, any attempts to changing the wallpaper will have no effect,
and any attempt to obtain of the wallpaper will return null.

Returns

boolean

peekDrawable

Retrieve the current system wallpaper; if there is no wallpaper set,
a null pointer is returned. This is returned as an
abstract Drawable that you can install in a View to display whatever
wallpaper the user has currently set.

Rect:
The rectangular subregion of fullImage that should be
displayed as wallpaper. Passing null for this parameter means that
the full image should be displayed if possible given the image's and device's
aspect ratios, etc.

allowBackup

boolean:
true if the OS is permitted to back up this wallpaper
image for restore to a future device; false otherwise.

which

int:
Flags indicating which wallpaper(s) to configure with the new imagery.

Returns

int

An integer ID assigned to the newly active wallpaper; or zero on failure.

setBitmap

Change the current system wallpaper to a bitmap, specifying a hint about
which subrectangle of the full image is to be visible. The OS will then
try to best present the given portion of the full image as the static system
wallpaper image. On success, the intent
ACTION_WALLPAPER_CHANGED is broadcast.

Rect:
The rectangular subregion of fullImage that should be
displayed as wallpaper. Passing null for this parameter means that
the full image should be displayed if possible given the image's and device's
aspect ratios, etc.

allowBackup

boolean:
true if the OS is permitted to back up this wallpaper
image for restore to a future device; false otherwise.

Returns

int

An integer ID assigned to the newly active wallpaper; or zero on failure.

setResource

Change the current system wallpaper to the bitmap in the given resource.
The resource is opened as a raw data stream and copied into the
wallpaper; it must be a valid PNG or JPEG image. On success, the intent
ACTION_WALLPAPER_CHANGED is broadcast.

setStream

Change the current system wallpaper to a specific byte stream. The
give InputStream is copied into persistent storage and will now be
used as the wallpaper. Currently it must be either a JPEG or PNG
image. On success, the intent ACTION_WALLPAPER_CHANGED
is broadcast.

InputStream:
A stream containing the raw data to install as a wallpaper. This
data can be in any format handled by BitmapRegionDecoder.

visibleCropHint

Rect:
The rectangular subregion of the streamed image that should be
displayed as wallpaper. Passing null for this parameter means that
the full image should be displayed if possible given the image's and device's
aspect ratios, etc.

allowBackup

boolean:
true if the OS is permitted to back up this wallpaper
image for restore to a future device; false otherwise.

which

int:
Flags indicating which wallpaper(s) to configure with the new imagery.

Returns

int

An integer ID assigned to the newly active wallpaper; or zero on failure.

setStream

Change the current system wallpaper to a specific byte stream, specifying a
hint about which subrectangle of the full image is to be visible. The OS will
then try to best present the given portion of the full image as the static system
wallpaper image. The data from the given InputStream is copied into persistent
storage and will then be used as the system wallpaper. Currently the data must
be either a JPEG or PNG image. On success, the intent
ACTION_WALLPAPER_CHANGED is broadcast.

InputStream:
A stream containing the raw data to install as a wallpaper. This
data can be in any format handled by BitmapRegionDecoder.

visibleCropHint

Rect:
The rectangular subregion of the streamed image that should be
displayed as wallpaper. Passing null for this parameter means that
the full image should be displayed if possible given the image's and device's
aspect ratios, etc.

allowBackup

boolean:
true if the OS is permitted to back up this wallpaper
image for restore to a future device; false otherwise.

Returns

int

An integer ID assigned to the newly active wallpaper; or zero on failure.

setWallpaperOffsetSteps

For applications that use multiple virtual screens showing a wallpaper,
specify the step size between virtual screens. For example, if the
launcher has 3 virtual screens, it would specify an xStep of 0.5,
since the X offset for those screens are 0.0, 0.5 and 1.0

Parameters

xStep

float:
The X offset delta from one screen to the next one

yStep

float:
The Y offset delta from one screen to the next one

setWallpaperOffsets

Set the display position of the current wallpaper within any larger space, when
that wallpaper is visible behind the given window. The X and Y offsets
are floating point numbers ranging from 0 to 1, representing where the
wallpaper should be positioned within the screen space. These only
make sense when the wallpaper is larger than the display.

suggestDesiredDimensions

For use only by the current home application, to specify the size of
wallpaper it would like to use. This allows such applications to have
a virtual wallpaper that is larger than the physical screen, matching
the size of their workspace.

Note developers, who don't seem to be reading this. This is
for home apps to tell what size wallpaper they would like.
Nobody else should be calling this! Certainly not other non-home
apps that change the wallpaper. Those apps are supposed to
retrieve the suggested size so they can construct a wallpaper
that matches it.