First, prepare two images with the same content. The specifications are 107 × 80 640 × 480, and the format is JPG. Then, name them wallpaper_papername_small and wallpaper_papername respectively. Papername is the name you give to the image. The small image is used to display in the gallery control that selects wallpaper. Wallpaper_papername is the wallpaper image.
Put the image in the/packages/apps/launcher2/RES/drawable-mdpi directory. Add <item> wallpaper_papername </item> to the file/packages/apps/launcher2/RES/Values-mdpi/wallpapers. xml.
<?xml version="1.0" encoding="utf-8"?><resources> <string-array name="wallpapers" translatable="false"> <item>wallpaper_lake</item> <item>wallpaper_sunset</item> <item>wallpaper_beach</item> <item>wallpaper_snow_leopard</item> <item>wallpaper_path</item> <item>wallpaper_sunrise</item> <item>wallpaper_mountain</item> <item>wallpaper_road</item> <item>wallpaper_jellyfish</item> <item>wallpaper_zanzibar</item> <item>wallpaper_blue</item> <item>wallpaper_grey</item> <item>wallpaper_green</item> <item>wallpaper_pink</item> <item>wallpaper_leaves</item> </string-array></resources>
If you do not want to modify the luncher source code, but want to modify the wallpaper in your own program, you can use the following method:
First, we need to obtain the permission to set the wallpaper. Like other permissions, you only need to add the following configuration information to the configuration file.
<Uses-Permission Android: Name = "android. Permission. set_wallpaper"/>
Then, call the following code in the program to set the desktop Wallpaper:
Getapplicationcontext (). setwallpaper (Bitmap)