SubscribeSubscribe with Androidlift to get new post on mail.

Picasso image downloading and caching library

In this tutorial, we will take a look into how to use Picasso library in android. Picasso is open source and one of the widely used image downloader library in Android. It is created and maintained by Square.

Popular Android image library for android.It simplifies the process of displaying images from all locations like External(URL) , internal(URI), file. In many cases only a few lines of code is required to implement this neat library.It shines displaying remote images.

The library handles every the process, from the initial HTTP request to the caching of the image.

Output :

Picasso Android libray
Picasso Android libray

Other alternatives instead of Picasso-

  1. Universal Image Loader.
  2. Volley.

How to use Picasso library in Eclipse –

Download the Picasso JAR file, If you haven’t done it already. If you are using eclipse as your development IDE, then just copy the downloaded picasso-2.4.0.jar file into your application lib folder.

How to use Picasso library in Android Studio-

MAVEN –

GRADLE –

Loading Remote Image in ImageView –

We are done with configuration, let us see how to use this library to download images from remote server and display in ImageView. I assume you have your activity layout file already with ImageView declared on it.

To download image from server we need Internet permission so we have to add internet permission in our AndroidManifest.xml file

Now let us download the image and display on imageView

Placeholder And Error Fallback –

Picasso supports both download and error placeholders as optional features.In the above code snippet, we have just downloaded the image and displayed on ImageView. But that is not enough always. For any real time application, you must think of all possible cases. Now we need an placeholder and error fallback for our ImageView. Placeholder image will be shown before the image is loaded. Error fallback will be shown if, there is an error while downloading image. However both fallback and placeholder are optional.

A request will be retried three times before the error placeholder is shown.

Image Resize and Transformation – 

Picasso offers much more rather than just downloading image. It can resize the image, transform in any degree before it is displayed in ImageView.

RESOURCE LOADING – 

Resources, assets, files, content providers are all supported as image sources.

DEBUG INDICATORS – 

For development you can enable the display of a colored ribbon which indicates the image source. Call setIndicatorsEnabled(true)on the Picasso instance.

Have a good day….! :0)

 

(64)

  • Yogesh

    Very Nice … Post its helps me lot … Thank u Android Lift

    • galaxystechnology@gmail.com

      Thanks Yogesh.