-1

I want to set image from the internet as wallpaper, but WallpaperManager works only with Id of image, which is Int type.

My solution is to download image from internet Picaso

Picasso.from(mContext).load(url).into(imageView);

and after to find ID of that image and put it in WallpaperManager

WallpaperManager myWallpaperManager
                = WallpaperManager.getInstance(getContext());
        try {
            myWallpaperManager.setResource(loadedImage)
 } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

Question: How to find ID of that image?

Pavel Coder
  • 33
  • 2
  • 7
  • You need to save the image into a target instead of setting into an ImageView. See this answer: https://stackoverflow.com/questions/32799353/saving-image-from-url-using-picasso – Basant Singh Feb 23 '18 at 08:28

1 Answers1

2

you can try this:

Picasso.with(this) .load(imageUrl).centerCrop() .into(new Target() { 
 @Override 
  public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { 
      myWallpaperManager.setBitmap(bitmap)
}
abby
  • 157
  • 4