Search code examples
androidlive-wallpaperwallpaper

android wallpaper image path


I need to get the path of the image currently serving as a background image in the wallpaper.

I managed to get the bitmap itself (using the drawable from the wallpaper manager) - but i dont need the drawable- i need the path so i can save it in sharedpreferences and use it later.

final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
final Drawable wallpaperDrawable = wallpaperManager.getDrawable();
final Bitmap wallpaperBitmap =drawableToBitmap(wallpaperDrawable); 

btw, according to The wallpapermanager's manual i cant use getWallpaperInfo since it will return null if its not a live wallpaper.

thanks for any help


Solution

  • try below code

    Drawable wallpaper = peekWallpaper();
    final Bitmap wallpaperBitmap =drawableToBitmap(wallpaper);
    

    and for absolute path follow this https://android.stackexchange.com/a/27709