Here is sample code:
WallpaperManager wallpaperManager1 = WallpaperManager
.getInstance(getApplicationContext());
final Drawable wallpaperDrawable1 = wallpaperManager1.getDrawable();
getWindow().setBackgroundDrawable(wallpaperDrawable1);
if (wallpaperDrawable1==null)
{
Resources res = getResources();
Drawable drawable1=res.getDrawable(R.drawable.bg1);
getWindow().setBackgroundDrawable(drawable1);
}
I wanted to get the system background in my app, If its not there or if user removes it, then I wanted to set a default image from my app to set as app background. Hope Its all clear….
To see if current system has wallpaper, you use
peekDrawable():Also, you missed
else: