List of usage examples for android.app WallpaperManager setBitmap
@RequiresPermission(android.Manifest.permission.SET_WALLPAPER) public void setBitmap(Bitmap bitmap) throws IOException
From source file:nf.frex.android.FrexActivity.java
private void setWallpaper(WallpaperManager wallpaperManager, Image image) { try {//from w w w . j a va 2s . c o m wallpaperManager.setBitmap(image.createBitmap()); alert(R.string.wallpaper_set_msg); } catch (OutOfMemoryError e) { alert(getString(R.string.out_of_memory)); } catch (IOException e) { alert(e.getLocalizedMessage()); } }
From source file:com.pk.wallpapermanager.PkWallpaperManager.java
/** * Sets the system wallpaper to the Wallpaper object passed. * May throw an exception if the data is invalid. * <p>//w w w .j ava 2 s.c o m * Note: Do NOT call this from the main UI thread if you're * setting it to a cloud wallpaper! Call setWallpaperAsync instead. * * @param mWall * @throws NumberFormatException * @throws IOException */ public void setWallpaper(Wallpaper mWall) throws NumberFormatException, IOException { if (debugEnabled) Log.d(LOG_TAG, "Setting wallpaper..."); // Load the original system WallpaperManager WallpaperManager wallManager = WallpaperManager.getInstance(mContext); Bitmap bitmap = null; // Set resource if local, otherwise download it and set it if (mWall.isLocal()) wallManager.setResource(mWall.getFullResource()); else { bitmap = getBitmapFromURL(mWall.getFullURL()); wallManager.setBitmap(bitmap); } // Loop through all listeners notifying them for (WallpaperSetListener mListener : mWallpaperSetListeners) { mListener.onWallpaperSet(bitmap); } if (debugEnabled) Log.d(LOG_TAG, "Successfully set wallpaper!"); }