public class WallpaperManager extends Object
getInstance()
.Modifier and Type | Field and Description |
---|---|
static String |
ACTION_CHANGE_LIVE_WALLPAPER
Directly launch live wallpaper preview, allowing the user to immediately
confirm to switch to a specific live wallpaper.
|
static String |
ACTION_LIVE_WALLPAPER_CHOOSER
Launch an activity for the user to pick the current global live
wallpaper.
|
static String |
COMMAND_DROP
Command for
sendWallpaperCommand(android.os.IBinder, java.lang.String, int, int, int, android.os.Bundle) : reported by the wallpaper
host when the user drops an object into an area of the host. |
static String |
COMMAND_SECONDARY_TAP
Command for
sendWallpaperCommand(android.os.IBinder, java.lang.String, int, int, int, android.os.Bundle) : reported by the wallpaper
host when the user releases a secondary pointer on an empty area
(not performing an action in the host). |
static String |
COMMAND_TAP
Command for
sendWallpaperCommand(android.os.IBinder, java.lang.String, int, int, int, android.os.Bundle) : reported by the wallpaper
host when the user taps on an empty area (not performing an action
in the host). |
static 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. |
static String |
WALLPAPER_PREVIEW_META_DATA
Manifest entry for activities that respond to
Intent.ACTION_SET_WALLPAPER
which allows them to provide a custom large icon associated with this action. |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove any currently set wallpaper, reverting to the system's default
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.
|
Bitmap |
getBitmap()
Like
getDrawable() but returns a Bitmap. |
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 default 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.
|
IWallpaperManager |
getIWallpaperManager() |
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.
|
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.
|
void |
setBitmap(Bitmap bitmap)
Change the current system wallpaper to a bitmap.
|
void |
setResource(int resid)
Change the current system wallpaper to the bitmap in the given resource.
|
void |
setStream(InputStream data)
Change the current system wallpaper to a specific byte stream.
|
void |
setWallpaperOffsets(IBinder windowToken,
float xOffset,
float yOffset)
Set the position of the current wallpaper within any larger space, when
that wallpaper is visible behind the given window.
|
void |
setWallpaperOffsetSteps(float xStep,
float yStep)
For applications that use multiple virtual screens showing a wallpaper,
specify the step size between virtual screens.
|
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.
|
public static final String ACTION_LIVE_WALLPAPER_CHOOSER
public static final String ACTION_CHANGE_LIVE_WALLPAPER
EXTRA_LIVE_WALLPAPER_COMPONENT
with the ComponentName of
a live wallpaper component that is to be shown.public static final String EXTRA_LIVE_WALLPAPER_COMPONENT
ACTION_CHANGE_LIVE_WALLPAPER
that specifies the
ComponentName of a live wallpaper that should be shown as a preview,
for the user to confirm.public static final String WALLPAPER_PREVIEW_META_DATA
Intent.ACTION_SET_WALLPAPER
which allows them to provide a custom large icon associated with this action.public static final String COMMAND_TAP
sendWallpaperCommand(android.os.IBinder, java.lang.String, int, int, int, android.os.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.public static final String COMMAND_SECONDARY_TAP
sendWallpaperCommand(android.os.IBinder, java.lang.String, int, int, int, android.os.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.public static final String COMMAND_DROP
sendWallpaperCommand(android.os.IBinder, java.lang.String, int, int, int, android.os.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.public static WallpaperManager getInstance(Context context)
public IWallpaperManager getIWallpaperManager()
public Drawable getDrawable()
public Drawable peekDrawable()
public Drawable getFastDrawable()
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).public Drawable peekFastDrawable()
getFastDrawable()
, but if there is no wallpaper set,
a null pointer is returned.public Bitmap getBitmap()
getDrawable()
but returns a Bitmap.public void forgetLoadedWallpaper()
public WallpaperInfo getWallpaperInfo()
public void setResource(int resid) throws IOException
Intent.ACTION_WALLPAPER_CHANGED
is broadcast.
This method requires the caller to hold the permission
android.Manifest.permission#SET_WALLPAPER
.
resid
- The bitmap to save.IOException
- If an error occurs reverting to the default
wallpaper.public void setBitmap(Bitmap bitmap) throws IOException
Intent.ACTION_WALLPAPER_CHANGED
is broadcast.
This method requires the caller to hold the permission
android.Manifest.permission#SET_WALLPAPER
.
bitmap
- The bitmap to save.IOException
- If an error occurs reverting to the default
wallpaper.public void setStream(InputStream data) throws IOException
Intent.ACTION_WALLPAPER_CHANGED
is broadcast.
This method requires the caller to hold the permission
android.Manifest.permission#SET_WALLPAPER
.
data
- A stream containing the raw data to install as a wallpaper.IOException
- If an error occurs reverting to the default
wallpaper.public boolean hasResourceWallpaper(int resid)
setResource(int)
with the same resource id.public int getDesiredMinimumWidth()
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.public int getDesiredMinimumHeight()
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.public void suggestDesiredDimensions(int minimumWidth, int minimumHeight)
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
android.Manifest.permission#SET_WALLPAPER_HINTS
.
minimumWidth
- Desired minimum widthminimumHeight
- Desired minimum heightpublic void setWallpaperOffsets(IBinder windowToken, float xOffset, float yOffset)
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.public void setWallpaperOffsetSteps(float xStep, float yStep)
xStep
- The X offset delta from one screen to the next oneyStep
- The Y offset delta from one screen to the next onepublic void sendWallpaperCommand(IBinder windowToken, String action, int x, int y, int z, Bundle extras)
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.public void clearWallpaperOffsets(IBinder windowToken)
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()
.public void clear() throws IOException
Intent.ACTION_WALLPAPER_CHANGED
is broadcast.
This method requires the caller to hold the permission
android.Manifest.permission#SET_WALLPAPER
.
IOException
- If an error occurs reverting to the default
wallpaper.