get image of current live wallpaper
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;
Yah you can take screenshot using your androing phone's volume down key + lock key Press Volume down key + lock key at a same time you can take a screen shot.
For android and pc wallpaper
链接地址: http://www.djcxy.com/p/62086.html上一篇: 获取字符串和csv的正确编码
下一篇: 获取当前动态壁纸的图像