Saturday , November 17 2018
Home / Android / How to download images from server in android application ?

How to download images from server in android application ?

In this tutorial we will show how to use picasso library in Android. Picasso is open source and widely used image downloader library in android.

There are various methods for downloading images from server . From which Picasso library is widely used for this purpose.It is easy to use.

How to use ? 

By the use of only single line code you can download any number of images from server.

Step :1  Firstly 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. If you are using Android Studio IDE, then you have to add below dependency in build.gradle file.

dependencies { compile “com.squareup.picasso:picasso:2.4.0″ }

Step :2 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.

Step :3 For Picasso download image from server, you need to add below internet permissions to your project’s manifest.

<uses-permission android:name=“android.permission.INTERNET” />

Step :4 Now let us download the image and display on imageView

In the first line we are getting ImageView instance from the layout. And then load the image from the above remote url using Picasso library.

Placeholder ,Error Fallback Image , Resize and Transformation

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

 

 

About admin

Check Also

Android Activity Launch Modes

Launch mode is an instruction for Android OS which specifies how the activity should be ...

Leave a Reply