I have this code which allows me to set the current device wallpaper as my activitys background.
public void wallpaperBackground()
{
WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
Drawable wallpaperDrawable = wallpaperManager.getDrawable();
View root = findViewById(R.id.home_view);
root.setBackground(wallpaperDrawable);
}
The problem is, if I change the wallpaper via settings it doesn't update on my app and I'm left with the previous wallpaper. How can I fix this?
It is quite easy actually:
Just call your wallpaperBackground()
method in onResume()
in your activity.
This will automatically apply the correct wallpaper when the activity resumes after the user comes back from another app.