someone someone - 1 year ago 43
Android Question

android change wallpaper

I'm trying to change wallpaper on galaxy sIII (ICS os) device I'm using 1280x1440 jpeg image by this code:

<uses-permission android:name="android.permission.SET_WALLPAPER"/>


Bitmap m = BitmapFactory.decodeByteArray(data, 0, data.length);

which is not working and following not working also:

Bitmap m = BitmapFactory.decodeResource(getResources(), R.drawable.data_img);

but when i use this:


it was work perfectly but my case is download some image data save it as bitmap then set it as wallpaper. so loading resources is not functional in my case.

any help, thanks in advance.

Answer Source

You can find the documentation here.

You have to use public void setStream (InputStream data) method:

InputStream ins = new URL("absolute/path/of/image").openStream();
WallpaperManager wpm = WallpaperManager.getInstance(context);

OR, if you have image URI then use:

WallpaperManager wpm = WallpaperManager.getInstance(context);