Skip to content

Most visited

Recently visited

navigation

WallpaperManager

public class WallpaperManager
extends Object

java.lang.Object
   ↳ android.app.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().

An app can check whether wallpapers are supported for the current user, by calling isWallpaperSupported(), and whether setting of wallpapers is allowed, by calling isSetWallpaperAllowed().

Summary

Constants

String ACTION_CHANGE_LIVE_WALLPAPER

Directly launch live wallpaper preview, allowing the user to immediately confirm to switch to a specific live wallpaper.

String ACTION_CROP_AND_SET_WALLPAPER

Activity Action: Show settings for choosing wallpaper.

String ACTION_LIVE_WALLPAPER_CHOOSER

Launch an activity for the user to pick the current global live wallpaper.

String COMMAND_DROP

Command for sendWallpaperCommand(IBinder, String, int, int, int, Bundle): reported by the wallpaper host when the user drops an object into an area of the host.

String COMMAND_SECONDARY_TAP

Command for sendWallpaperCommand(IBinder, String, int, int, int, Bundle): reported by the wallpaper host when the user releases a secondary pointer on an empty area (not performing an action in the host).

String COMMAND_TAP

Command for sendWallpaperCommand(IBinder, String, int, int, int, Bundle): reported by the wallpaper host when the user taps on an empty area (not performing an action in the host).

String EXTRA_LIVE_WALLPAPER_COMPONENT

Extra in ACTION_CHANGE_LIVE_WALLPAPER that specifies the ComponentName of a live wallpaper that should be shown as a preview, for the user to confirm.

int FLAG_LOCK

Flag: set or retrieve the lock-screen-specific wallpaper.

int FLAG_SYSTEM

Flag: set or retrieve the general system wallpaper.

String WALLPAPER_PREVIEW_META_DATA

Manifest entry for activities that respond to ACTION_SET_WALLPAPER which allows them to provide a custom large icon associated with this action.

Public methods

void clear(int which)

Remove one or more currently set wallpapers, reverting to the system default display for each one.

void clear()

Remove any currently set system wallpaper, reverting to the system's built-in wallpaper.

void clearWallpaperOffsets(IBinder windowToken)

Clear the offsets previously associated with this window through setWallpaperOffsets(IBinder, float, float).

void forgetLoadedWallpaper()

Remove all internal references to the last loaded wallpaper.

Drawable getBuiltInDrawable(int outWidth, int outHeight, boolean scaleToFit, float horizontalAlignment, float verticalAlignment, int which)

Returns a drawable for the built-in static wallpaper of the specified type.

Drawable getBuiltInDrawable(int which)

Obtain a drawable for the specified built-in static system wallpaper.

Drawable getBuiltInDrawable(int outWidth, int outHeight, boolean scaleToFit, float horizontalAlignment, float verticalAlignment)

Returns a drawable for the system built-in static wallpaper.

Drawable getBuiltInDrawable()

Obtain a drawable for the built-in static system wallpaper.

Intent getCropAndSetWallpaperIntent(Uri imageUri)

Gets an Intent that will launch an activity that crops the given image and sets the device's wallpaper.

int getDesiredMinimumHeight()

Returns the desired minimum height for the wallpaper.

int getDesiredMinimumWidth()

Returns the desired minimum width for the wallpaper.

Drawable getDrawable()

Retrieve the current system wallpaper; if no wallpaper is set, the system built-in static wallpaper is returned.

Drawable getFastDrawable()

Like getDrawable(), but the returned Drawable has a number of limitations to reduce its overhead as much as possible.

static WallpaperManager getInstance(Context context)

Retrieve a WallpaperManager associated with the given Context.

ParcelFileDescriptor getWallpaperFile(int which)

Get an open, readable file descriptor to the given wallpaper image file.

int getWallpaperId(int which)

Get the ID of the current wallpaper of the given kind.

WallpaperInfo getWallpaperInfo()

If the current wallpaper is a live wallpaper component, return the information about that wallpaper.

boolean hasResourceWallpaper(int resid)

Return whether any users are currently set to use the wallpaper with the given resource ID.

boolean isSetWallpaperAllowed()

Returns whether the calling package is allowed to set the wallpaper for the calling user.

boolean isWallpaperSupported()

Returns whether wallpapers are supported for the calling user.

Drawable peekDrawable()

Retrieve the current system wallpaper; if there is no wallpaper set, a null pointer is returned.

Drawable peekFastDrawable()

Like getFastDrawable(), but if there is no wallpaper set, a null pointer is returned.

void sendWallpaperCommand(IBinder windowToken, String action, int x, int y, int z, Bundle extras)

Send an arbitrary command to the current active wallpaper.

int setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup, int which)

Version of setBitmap(Bitmap, Rect, boolean) that allows the caller to specify which of the supported wallpaper categories to set.

void setBitmap(Bitmap bitmap)

Change the current system wallpaper to a bitmap.

int setBitmap(Bitmap fullImage, Rect visibleCropHint, boolean allowBackup)

Change the current system wallpaper to a bitmap, specifying a hint about which subrectangle of the full image is to be visible.

int setResource(int resid, int which)

Version of setResource(int) that allows the caller to specify which of the supported wallpaper categories to set.

void setResource(int resid)

Change the current system wallpaper to the bitmap in the given resource.

void setStream(InputStream bitmapData)

Change the current system wallpaper to a specific byte stream.

int setStream(InputStream bitmapData, Rect visibleCropHint, boolean allowBackup, int which)

Version of setStream(InputStream, Rect, boolean) that allows the caller to specify which of the supported wallpaper categories to set.

int setStream(InputStream bitmapData, Rect visibleCropHint, boolean allowBackup)

Change the current system wallpaper to a specific byte stream, specifying a hint about which subrectangle of the full image is to be visible.

void setWallpaperOffsetSteps(float xStep, float yStep)

For applications that use multiple virtual screens showing a wallpaper, specify the step size between virtual screens.

void setWallpaperOffsets(IBinder windowToken, float xOffset, float yOffset)

Set the display position of the current wallpaper within any larger space, when that wallpaper is visible behind the given window.

void suggestDesiredDimensions(int minimumWidth, int minimumHeight)

For use only by the current home application, to specify the size of wallpaper it would like to use.

Inherited methods

From class java.lang.Object

Constants

ACTION_CHANGE_LIVE_WALLPAPER

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

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

ACTION_CROP_AND_SET_WALLPAPER

Added in API level 19
String ACTION_CROP_AND_SET_WALLPAPER

Activity Action: Show settings for choosing wallpaper. Do not use directly to construct an intent; instead, use getCropAndSetWallpaperIntent(Uri).

Input: getData() is the URI of the image to crop and set as wallpaper.

Output: RESULT_OK if user decided to crop/set the wallpaper, RESULT_CANCEL otherwise Activities that support this intent should specify a MIME filter of "image/*"

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

ACTION_LIVE_WALLPAPER_CHOOSER

Added in API level 7
String ACTION_LIVE_WALLPAPER_CHOOSER

Launch an activity for the user to pick the current global live wallpaper.

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

COMMAND_DROP

Added in API level 7
String COMMAND_DROP

Command for sendWallpaperCommand(IBinder, String, int, int, int, Bundle): reported by the wallpaper host when the user drops an object into an area of the host. The x and y arguments are the location of the drop.

Constant Value: "android.home.drop"

COMMAND_SECONDARY_TAP

Added in API level 11
String COMMAND_SECONDARY_TAP

Command for sendWallpaperCommand(IBinder, String, int, int, int, Bundle): reported by the wallpaper host when the user releases a secondary pointer on an empty area (not performing an action in the host). The x and y arguments are the location of the secondary tap in screen coordinates.

Constant Value: "android.wallpaper.secondaryTap"

COMMAND_TAP

Added in API level 7
String COMMAND_TAP

Command for sendWallpaperCommand(IBinder, String, int, int, int, Bundle): reported by the wallpaper host when the user taps on an empty area (not performing an action in the host). The x and y arguments are the location of the tap in screen coordinates.

Constant Value: "android.wallpaper.tap"

EXTRA_LIVE_WALLPAPER_COMPONENT

Added in API level 16
String EXTRA_LIVE_WALLPAPER_COMPONENT

Extra in ACTION_CHANGE_LIVE_WALLPAPER that specifies the ComponentName of a live wallpaper that should be shown as a preview, for the user to confirm.

Constant Value: "android.service.wallpaper.extra.LIVE_WALLPAPER_COMPONENT"

FLAG_LOCK

Added in API level 24
int FLAG_LOCK

Flag: set or retrieve the lock-screen-specific wallpaper.

Constant Value: 2 (0x00000002)

FLAG_SYSTEM

Added in API level 24
int FLAG_SYSTEM

Flag: set or retrieve the general system wallpaper.

Constant Value: 1 (0x00000001)

WALLPAPER_PREVIEW_META_DATA

Added in API level 11
String WALLPAPER_PREVIEW_META_DATA

Manifest entry for activities that respond to ACTION_SET_WALLPAPER which allows them to provide a custom large icon associated with this action.

Constant Value: "android.wallpaper.preview"

Public methods

clear

Added in API level 24
void clear (int which)

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.

Parameters
which int: A bitwise combination of FLAG_SYSTEM or FLAG_LOCK
Throws
IOException If an error occurs reverting to the built-in wallpaper.

clear

Added in API level 5
void clear ()

Remove any currently set system wallpaper, reverting to the system's built-in wallpaper. On success, the intent ACTION_WALLPAPER_CHANGED is broadcast.

This method requires the caller to hold the permission SET_WALLPAPER.

Throws
IOException If an error occurs reverting to the built-in wallpaper.

clearWallpaperOffsets

Added in API level 5
void clearWallpaperOffsets (IBinder windowToken)

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.

Parameters
windowToken IBinder: The window who these offsets should be associated with, as returned by View.getWindowToken().

forgetLoadedWallpaper

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

getBuiltInDrawable

Added in API level 24
Drawable getBuiltInDrawable (int outWidth, 
                int outHeight, 
                boolean scaleToFit, 
                float horizontalAlignment, 
                float verticalAlignment, 
                int which)

Returns a drawable for the built-in static wallpaper of the specified type. Based on the parameters, the drawable can be cropped and scaled.

Parameters
outWidth int: The width of the returned drawable
outHeight int
scaleToFit boolean: If true, scale the wallpaper down rather than just cropping it
horizontalAlignment float: A float value between 0 and 1 specifying where to crop the image; 0 for left-aligned, 0.5 for horizontal center-aligned, and 1 for right-aligned
verticalAlignment float: A float value between 0 and 1 specifying where to crop the image; 0 for top-aligned, 0.5 for vertical center-aligned, and 1 for bottom-aligned
which int: The FLAG_* identifier of a valid wallpaper type. Throws IllegalArgumentException if an invalid wallpaper is requested.
Returns
Drawable A Drawable presenting the built-in default wallpaper image of the given type, or null if no default image of that type is defined on this device.

getBuiltInDrawable

Added in API level 24
Drawable getBuiltInDrawable (int which)

Obtain a drawable for the specified built-in static system wallpaper.

Parameters
which int: The FLAG_* identifier of a valid wallpaper type. Throws IllegalArgumentException if an invalid wallpaper is requested.
Returns
Drawable A Drawable presenting the specified wallpaper image, or null if no built-in default image for that wallpaper type exists.

getBuiltInDrawable

Added in API level 19
Drawable getBuiltInDrawable (int outWidth, 
                int outHeight, 
                boolean scaleToFit, 
                float horizontalAlignment, 
                float verticalAlignment)

Returns a drawable for the system built-in static wallpaper. Based on the parameters, the drawable can be cropped and scaled

Parameters
outWidth int: The width of the returned drawable
outHeight int
scaleToFit boolean: If true, scale the wallpaper down rather than just cropping it
horizontalAlignment float: A float value between 0 and 1 specifying where to crop the image; 0 for left-aligned, 0.5 for horizontal center-aligned, and 1 for right-aligned
verticalAlignment float: A float value between 0 and 1 specifying where to crop the image; 0 for top-aligned, 0.5 for vertical center-aligned, and 1 for bottom-aligned
Returns
Drawable A Drawable presenting the built-in default system wallpaper image, or null if no such default image is defined on this device.

getBuiltInDrawable

Added in API level 19
Drawable getBuiltInDrawable ()

Obtain a drawable for the built-in static system wallpaper.

Returns
Drawable

getCropAndSetWallpaperIntent

Added in API level 19
Intent getCropAndSetWallpaperIntent (Uri imageUri)

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/*"
Returns
Intent
Throws
IllegalArgumentException if the URI is not a content URI or its MIME type is not "image/*"

getDesiredMinimumHeight

Added in API level 5
int 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

Added in API level 5
int 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

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

Returns
Drawable Returns a Drawable object that will draw the wallpaper.

getFastDrawable

Added in API level 5
Drawable 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).

Returns
Drawable Returns a Drawable object that will draw the wallpaper.

getInstance

Added in API level 5
WallpaperManager getInstance (Context context)

Retrieve a WallpaperManager associated with the given Context.

Parameters
context Context
Returns
WallpaperManager

getWallpaperFile

Added in API level 24
ParcelFileDescriptor getWallpaperFile (int which)

Get an open, readable file descriptor to the given wallpaper image file. The caller is responsible for closing the file descriptor when done ingesting the file.

If no lock-specific wallpaper has been configured for the given user, then this method will return null when requesting FLAG_LOCK rather than returning the system wallpaper's image file.

Parameters
which int: The wallpaper whose image file is to be retrieved. Must be a single defined kind of wallpaper, either FLAG_SYSTEM or FLAG_LOCK.
Returns
ParcelFileDescriptor

See also:

getWallpaperId

Added in API level 24
int getWallpaperId (int which)

Get the ID of the current wallpaper of the given kind. If there is no such wallpaper configured, returns a negative number.

Every time the wallpaper image is set, a new ID is assigned to it. This method allows the caller to determine whether the wallpaper imagery has changed, regardless of how that change happened.

Parameters
which int: The wallpaper whose ID is to be returned. Must be a single defined kind of wallpaper, either FLAG_SYSTEM or FLAG_LOCK.
Returns
int The positive numeric ID of the current wallpaper of the given kind, or a negative value if no such wallpaper is configured.

getWallpaperInfo

Added in API level 7
WallpaperInfo getWallpaperInfo ()

If the current wallpaper is a live wallpaper component, return the information about that wallpaper. Otherwise, if it is a static image, simply return null.

Returns
WallpaperInfo

hasResourceWallpaper

Added in API level 17
boolean hasResourceWallpaper (int resid)

Return whether any users are currently set to use the wallpaper with the given resource ID. That is, their wallpaper has been set through setResource(int) with the same resource id.

Parameters
resid int
Returns
boolean

isSetWallpaperAllowed

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

Returns
boolean

See also:

isWallpaperSupported

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

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

Returns
Drawable Returns a Drawable object that will draw the wallpaper or a null pointer if these is none.

peekFastDrawable

Added in API level 5
Drawable peekFastDrawable ()

Like getFastDrawable(), but if there is no wallpaper set, a null pointer is returned.

Returns
Drawable Returns an optimized Drawable object that will draw the wallpaper or a null pointer if these is none.

sendWallpaperCommand

Added in API level 7
void sendWallpaperCommand (IBinder windowToken, 
                String action, 
                int x, 
                int y, 
                int z, 
                Bundle extras)

Send an arbitrary command to the current active wallpaper.

Parameters
windowToken IBinder: The window who these offsets should be associated with, as returned by View.getWindowToken().
action String: Name of the command to perform. This must be a scoped name to avoid collisions, such as "com.mycompany.wallpaper.DOIT".
x int: Arbitrary integer argument based on command.
y int: Arbitrary integer argument based on command.
z int: Arbitrary integer argument based on command.
extras Bundle: Optional additional information for the command, or null.

setBitmap

Added in API level 24
int setBitmap (Bitmap fullImage, 
                Rect visibleCropHint, 
                boolean allowBackup, 
                int which)

Version of setBitmap(Bitmap, Rect, boolean) that allows the caller to specify which of the supported wallpaper categories to set.

Parameters
fullImage Bitmap: A bitmap that will supply the wallpaper imagery.
visibleCropHint 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.
Throws
IOException

See also:

setBitmap

Added in API level 5
void setBitmap (Bitmap bitmap)

Change the current system wallpaper to a bitmap. The given bitmap is converted to a PNG and stored as the wallpaper. On success, the intent ACTION_WALLPAPER_CHANGED is broadcast.

This method is equivalent to calling setBitmap(Bitmap, Rect, boolean) and passing null for the visibleCrop rectangle and true for the allowBackup parameter.

This method requires the caller to hold the permission SET_WALLPAPER.

Parameters
bitmap Bitmap: The bitmap to be used as the new system wallpaper.
Throws
IOException If an error occurs when attempting to set the wallpaper to the provided image.

setBitmap

Added in API level 24
int setBitmap (Bitmap fullImage, 
                Rect visibleCropHint, 
                boolean allowBackup)

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.

Passing null as the visibleHint parameter is equivalent to passing (0, 0, fullImage.getWidth(), fullImage.getHeight()).

This method requires the caller to hold the permission SET_WALLPAPER.

Parameters
fullImage Bitmap: A bitmap that will supply the wallpaper imagery.
visibleCropHint 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.
Throws
IOException If an error occurs when attempting to set the wallpaper to the provided image.
IllegalArgumentException If the visibleCropHint rectangle is empty or invalid.

setResource

Added in API level 24
int setResource (int resid, 
                int which)

Version of setResource(int) that allows the caller to specify which of the supported wallpaper categories to set.

Parameters
resid int: The resource ID of the bitmap to be used as the wallpaper image
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.
Throws
IOException

See also:

setResource

Added in API level 5
void setResource (int resid)

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.

This method requires the caller to hold the permission SET_WALLPAPER.

Parameters
resid int: The resource ID of the bitmap to be used as the wallpaper image
Throws
IOException If an error occurs reverting to the built-in wallpaper.

setStream

Added in API level 5
void setStream (InputStream bitmapData)

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.

This method is equivalent to calling setStream(InputStream, Rect, boolean) and passing null for the visibleCrop rectangle and true for the allowBackup parameter.

This method requires the caller to hold the permission SET_WALLPAPER.

Parameters
bitmapData InputStream: A stream containing the raw data to install as a wallpaper. This data can be in any format handled by BitmapRegionDecoder.
Throws
IOException If an error occurs when attempting to set the wallpaper based on the provided image data.

setStream

Added in API level 24
int setStream (InputStream bitmapData, 
                Rect visibleCropHint, 
                boolean allowBackup, 
                int which)

Version of setStream(InputStream, Rect, boolean) that allows the caller to specify which of the supported wallpaper categories to set.

Parameters
bitmapData 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.
Throws
IOException

See also:

setStream

Added in API level 24
int setStream (InputStream bitmapData, 
                Rect visibleCropHint, 
                boolean allowBackup)

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.

This method requires the caller to hold the permission SET_WALLPAPER.

Parameters
bitmapData 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.
Throws
IOException If an error occurs when attempting to set the wallpaper based on the provided image data.
IllegalArgumentException If the visibleCropHint rectangle is empty or invalid.

See also:

setWallpaperOffsetSteps

Added in API level 7
void setWallpaperOffsetSteps (float xStep, 
                float yStep)

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

Added in API level 5
void setWallpaperOffsets (IBinder windowToken, 
                float xOffset, 
                float yOffset)

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.

Parameters
windowToken IBinder: The window who these offsets should be associated with, as returned by View.getWindowToken().
xOffset float: The offset along the X dimension, from 0 to 1.
yOffset float: The offset along the Y dimension, from 0 to 1.

suggestDesiredDimensions

Added in API level 5
void suggestDesiredDimensions (int minimumWidth, 
                int minimumHeight)

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.

This method requires the caller to hold the permission SET_WALLPAPER_HINTS.

Parameters
minimumWidth int: Desired minimum width
minimumHeight int: Desired minimum height
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.