0

we are using an app for setting wallpaper in android device, for that we are doing below steps

1) we have set of images and URLs

2) We are fetching the URL on an Imageview

so now we have to set the wallpaper, for that we need the image file, which is the best way to do it? 1) Download the file directly from URL and store it in a local storage and use it as wallpaper.

or

2) Create a bitmap from the Imageview and use it as wallpaper.

Doing the second option will reduce any quality of the image we using? First option how to we can do it?

We have fetch the images successfully inside the application.

unitedartinc
  • 738
  • 1
  • 6
  • 25

2 Answers2

1

Always prefer to cache your image downloads so that you don't have to repeat the task. Using libraries like Picasso or Glide reduces a lot of effort is handling your images while at the same time optimizing your code.

Additionally it's best to use the original image as wallpaper rather than consuming the image view because if you have set any scale type's on your image view then your image will be cropped.

Kshitij Aggarwal
  • 5,287
  • 5
  • 34
  • 41
  • So that's why the quality is reduced when we create bitmap from imageview and use its uri to set wallpaper, we have done all image fetching part and loading part, and everything is so smooth right now, only thing we are pending is download the image and save it, can you guide on the same part, where we can save the image inside the local storage and use its uri. Thank you for the help – unitedartinc Jan 25 '16 at 06:40
  • Yes. Plus images loaded in image view are governed by the device specification and can be small/large or low/high quality depending on how big or good the screen is. Using a cached image will overcome all this hurdles. For manually storing the images to SD card, im sure you can do a quick search on SO to find a popular answer. – Kshitij Aggarwal Jan 25 '16 at 06:45
  • Thank you for understanding our case instead of finding the problem in our question :) Can you tell us how to save the image to the local storage, like apps will have their own folder and there we will have all downloaded images. right – unitedartinc Jan 25 '16 at 06:50
  • I think this should help you out http://stackoverflow.com/questions/25217495/download-images-from-url-to-sd-card – Kshitij Aggarwal Jan 25 '16 at 09:49
0

Picasso allows for hassle-free image loading in your application—often in one line of code!

Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);
Muhammad Younas
  • 1,543
  • 1
  • 22
  • 32