I want to set the wallpaper on phone boot. How can I do that ?
Asked
Active
Viewed 319 times
3 Answers
3
In your manifest add this permission:
<uses -permission android:name="android.permission.SET_WALLPAPER" />
Later in your code:
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable drawable = getResources().getDrawable(R.drawable.wallpaper);
Bitmap wallpaper = ((BitmapDrawable) drawable).getBitmap();
wallpaperManager.setBitmap(wallpaper);

Seshu Vinay
- 13,560
- 9
- 60
- 109
-
or add an image from sdcard ? – Alexander Fuchs Feb 20 '12 at 11:01
-
in Activity, Service or Broadcast Receivers, you can use it – Seshu Vinay Feb 20 '12 at 11:08
-
you have to use context.getResources() instead of getResources() – Seshu Vinay Feb 20 '12 at 11:15
-
and instead of 'this', use context\ – Seshu Vinay Feb 20 '12 at 11:15
2
You can use this method to set the wallpaper. Remember to put the wallpaper image in the res/raw directory.(You can add this manually if it hasn't been made yet)
public void setWall(){
InputStream wall = getResources().openRawResource(wallpaper);
Bitmap back = BitmapFactory.decodeStream(wall);
try {
getApplicationContext().setWallpaper(back);
}
catch(IOException e) {
e.printStackTrace();
}}
and ofcourse set the permission in the manifest with this:
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
This will set the wallpaper to your phone and will stay after a reboot.

crognar
- 65
- 1
- 7
0
use scheduler
of android
mostly crontab
write a script to pick wallpaper from a location
on a condition like change in date
schedule this script into the scheduler
at a particular time
so it will run at that time of day and will do your job

maxjackie
- 22,386
- 6
- 29
- 37
-
I think the question was to set the wallpaper at **Boot** time.... However information regarding crontab may be helpful in some cases....thanks for that!!! – Amit Feb 20 '12 at 10:04