I am working on an android app that extracts the most dominant colours from the current wallpaper using wallpapermanager and the new palette api. I have a problem now because I can't extract any colours when using a live wallpaper like muzei for example. How would I go on about that? There must be something like a check that would use something other than wallpapermanager if a live wallpaper is currently set. Or maybe there's the possibility of grabbing a screenshot of the live wallpaper?
Thanks!
Solution:
//Reference to the package manager instance
PackageManager pm = getApplicationContext().getPackageManager();
/*
* Wallpaper info is not equal to null, that is if the live wallpaper
* is set, then get the drawable image from the package for the
* live wallpaper
*/
Drawable wallpaperDrawable = null;
if (WallpaperManager.getInstance(this).getWallpaperInfo() != null) {
wallpaperDrawable = WallpaperManager.getInstance(this).getWallpaperInfo().loadThumbnail(pm);
}
/*
* Else, if static wallpapers are set, then directly get the
* wallpaper image
*/
else {
wallpaperDrawable = WallpaperManager.getInstance(this).getDrawable();
}
//Drawable wallpaperDrawable = WallpaperManager.getInstance(this).getDrawable();
//Toast.makeText(this,"Wallpaper Info: " + WallpaperManager.getInstance(this).getWallpaperInfo(), Toast.LENGTH_SHORT).show();
Drawable wallpaperDrawable2 = wallpaperDrawable;