Android - How to set the wallpaper image?

asdf.BEN picture asdf.BEN · Feb 5, 2010 · Viewed 24.3k times · Source

Possible Duplicate:
Android - how to set the wallpaper image

What i'm trying to do is, set the wallpaper using an image URI (no cropping)

I'm a noob at dev on Android and dev in general. The internet has failed me... on providing code to set the wallpaper.

yes the dev resource site says

public void setStream (InputStream data)

but i don't understand it, some sample code would greatly help me.

Answer

Maidul picture Maidul · Apr 28, 2011

Hi you can use this code if You have Image path.

is = new FileInputStream(new File(imagePath));
bis = new BufferedInputStream(is);
Bitmap bitmap = BitmapFactory.decodeStream(bis);
Bitmap useThisBitmap = Bitmap.createScaledBitmap(
    bitmap, parent.getWidth(), parent.getHeight(), true);
bitmap.recycle();
if(imagePath!=null){
    System.out.println("Hi I am try to open Bit map");
    wallpaperManager = WallpaperManager.getInstance(this);
    wallpaperDrawable = wallpaperManager.getDrawable();
    wallpaperManager.setBitmap(useThisBitmap);

if you have image URI then use this

wallpaperManager = WallpaperManager.getInstance(this);
wallpaperDrawable = wallpaperManager.getDrawable();
mImageView.setImageURI(imagepath);

Let me know if there is any issue .