Saturday, March 24, 2012

How to set wallpaper in ANDROID?


How to set wallpaper in ANDROID?

Following example shows how to set a Bitmap as wallpaper in ANDROID.
After running this code your wallpaper on the ANDROID phone will change.
Make sure that you have an image named ‘my_wallpaper’ in your drawable folder.
?
Drag and copy the code
1
2
3
4
5
6
7
8
Bitmap wallpaper = BitmapFactory.decodeStream(getResources().openRawResource(R.drawable.my_wallpaper));
        try
        {
                getApplicationContext().setWallpaper(wallpaper);
        } catch (IOException e)
        {
                e.printStackTrace();
        }

No comments: