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()
.
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.
|
|||||||||
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Remove any currently set wallpaper, reverting to the system's built-in
wallpaper.
|
||||||||||
|
Clear the offsets previously associated with this window through
setWallpaperOffsets(IBinder, float, float)
.
|
||||||||||
|
Remove all internal references to the last loaded wallpaper.
|
||||||||||
|
Returns a drawable for the system built-in static wallpaper .
|
||||||||||
|
Returns a drawable for the system built-in static wallpaper.
|
||||||||||
|
Gets an Intent that will launch an activity that crops the given
image and sets the device's wallpaper.
|
||||||||||
|
Returns the desired minimum height for the wallpaper.
|
||||||||||
|
Returns the desired minimum width for the wallpaper.
|
||||||||||
|
Retrieve the current system wallpaper; if
no wallpaper is set, the system built-in static wallpaper is returned.
|
||||||||||
|
Like
getDrawable()
, but the returned Drawable has a number
of limitations to reduce its overhead as much as possible.
|
||||||||||
|
Retrieve a WallpaperManager associated with the given Context.
|
||||||||||
|
If the current wallpaper is a live wallpaper component, return the
information about that wallpaper.
|
||||||||||
|
Return whether any users are currently set to use the wallpaper
with the given resource ID.
|
||||||||||
|
Retrieve the current system wallpaper; if there is no wallpaper set,
a null pointer is returned.
|
||||||||||
|
Like
getFastDrawable()
, but if there is no wallpaper set,
a null pointer is returned.
|
||||||||||
|
Send an arbitrary command to the current active wallpaper.
|
||||||||||
|
Change the current system wallpaper to a bitmap.
|
||||||||||
|
Change the current system wallpaper to the bitmap in the given resource.
|
||||||||||
|
Change the current system wallpaper to a specific byte stream.
|
||||||||||
|
For applications that use multiple virtual screens showing a wallpaper,
specify the step size between virtual screens.
|
||||||||||
|
Set the position of the current wallpaper within any larger space, when
that wallpaper is visible behind the given window.
|
||||||||||
|
For use only by the current home application, to specify the size of
wallpaper it would like to use.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
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.
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/*"
Launch an activity for the user to pick the current global live wallpaper.
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.
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.
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.
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.
Manifest entry for activities that respond to
ACTION_SET_WALLPAPER
which allows them to provide a custom large icon associated with this action.
Remove any currently set 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
.
IOException | If an error occurs reverting to the built-in wallpaper. |
---|
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.
windowToken |
The window who these offsets should be associated
with, as returned by
View.getWindowToken()
.
|
---|
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.
Returns a drawable for the system built-in static wallpaper .
Returns a drawable for the system built-in static wallpaper. Based on the parameters, the drawable can be cropped and scaled
outWidth | The height of the returned drawable |
---|---|
scaleToFit | If true, scale the wallpaper down rather than just cropping it |
horizontalAlignment | 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 | 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 |
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.
imageUri | 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/*" |
---|
IllegalArgumentException | if the URI is not a content URI or its MIME type is not "image/*" |
---|
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 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.
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.
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).
Retrieve a WallpaperManager associated with the given Context.
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.
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.
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.
Like
getFastDrawable()
, but if there is no wallpaper set,
a null pointer is returned.
Send an arbitrary command to the current active wallpaper.
windowToken |
The window who these offsets should be associated
with, as returned by
View.getWindowToken()
.
|
---|---|
action | Name of the command to perform. This must be a scoped name to avoid collisions, such as "com.mycompany.wallpaper.DOIT". |
x | Arbitrary integer argument based on command. |
y | Arbitrary integer argument based on command. |
z | Arbitrary integer argument based on command. |
extras | Optional additional information for the command, or null. |
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 requires the caller to hold the permission
SET_WALLPAPER
.
bitmap | The bitmap to save. |
---|
IOException | If an error occurs reverting to the built-in wallpaper. |
---|
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
.
resid | The bitmap to save. |
---|
IOException | If an error occurs reverting to the built-in wallpaper. |
---|
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 requires the caller to hold the permission
SET_WALLPAPER
.
data | A stream containing the raw data to install as a wallpaper. |
---|
IOException | If an error occurs reverting to the built-in wallpaper. |
---|
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
xStep | The X offset delta from one screen to the next one |
---|---|
yStep | The Y offset delta from one screen to the next one |
Set the 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 screen.
windowToken |
The window who these offsets should be associated
with, as returned by
View.getWindowToken()
.
|
---|---|
xOffset | The offset along the X dimension, from 0 to 1. |
yOffset | The offset along the Y dimension, from 0 to 1. |
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 screens to tell what size wallpaper they would like. Nobody else should be calling this! Certainly not other non-home-screen 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
.
minimumWidth | Desired minimum width |
---|---|
minimumHeight | Desired minimum height |