get image of current live wallpaper
Asked Answered
I

0

6

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;
Imperturbation answered 16/12, 2014 at 7:34 Comment(3)
Maybe you should have added your solution as an answer, you are allow to post an answer to your own question :)Downcome
With which lwp and android version was this working? Because it doesn't work with Muzei and Android 5.1. I only get a thumbnail, no live updated image.Syreetasyria
loadThumbnail returns the thumbnail not the wallpaper. So this doesn't workInsurgent

© 2022 - 2024 — McMap. All rights reserved.