Top 4 -Third Party Library For The Image Loading/Downloading In Android.

Here we will learn top 4 -third party library for the image loading in android.

Note:

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

Add the above code in AndroidManifest.xml.

1.Glide

Glide is a open source,fastest and efficient to use in android in which we can easily load/download the image in the ImageView.

It also support the Animated GIFs,decoding the videos and so different work.

Let’s start

Open the build.gradle file and put the code

dependencies
{
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationprocessor 'com.github.bumptech.glide:compiler:4.9.0'
}

Loading the image:

Here we will show one image in the ImageView.

import android.app.Activity;
public class GlideImageExample extens Activity
{
@Override
public void onCreate(Bundle SavedInstanceState)
{
super.onCreate(SavedInstanceState);
setContentview(R.layout.image);
Imageview image=(ImageView)findViewById(R.id.glide_image);
Glide.with(getApplicationContext)
     .load(http://image_url) //This is the image url which you want to display
     .centerCrop()
     .placeholder(R.drawable.image)
     .into(image);
}
}

2.Picasso

Picasso is another most powerful library for loading/downloading and caching the image in android.

Complex image can set in very easy manner with taking the less memory.

Let’s start

Open the build.gradle file and put the code:

dependencies
{
implementation 'com.squareup.picasso:picasso:'2.71828'
}

Loading the image:

Here we will show one image in the ImageView.

import android.app.Activity;
public class PicassoImageExample extens Activity
{
@Override
public void onCreate(Bundle SavedInstanceState)
{
super.onCreate(SavedInstanceState);
setContentview(R.layout.image);
Imageview image=(ImageView)findViewById(R.id.glide_image);
Glide.get()
     .load(http://image_url) //This is the image url which you want to display
     .centerCrop()
     .placeholder(R.drawable.image)
     .resize(40,40)
     .into(image);
}
}

Universal Image Loader

Universal image loader is another powerful and flexible library for the image loading.It is also open-source.

It is multi-threading means multiple image can cache asynchronously.

It also cache the images from the SD card or memory.

Let’s start

Open the build.gradle file and put the code:

dependencies
{
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
}

Loading the image


Here we will show one image in the ImageView.

import android.app.Activity;
public class UniversalImageLoaderExample extens Activity
{
@Override
public void onCreate(Bundle SavedInstanceState)
{
super.onCreate(SavedInstanceState);
setContentview(R.layout.image);
Imageview image=(ImageView)findViewById(R.id.glide_image);
String url="https://image_url";//This is the imageurl
ImageLoader imageloader=ImageLoader.getInstance();
DisplayImageOptions imageOptions=new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnLoading(fallback).build();
//displaying the image on the imageview
imageloader.displayImage(url,image,imageOptions);

}
}

Fresco

Fresco is also important library which is used to displaying the image in android.

It also loads the image from the network ,internal or external storage.

Let’s start

Open the build.gradle file and put the code:

dependencies
{
implementation 'com.facebook.fresco:fresco:1.13.0'
}

Loading the image

Here we will show one image in SimpleDraweeView.

import android.app.Activity;
public class UniversalImageLoaderExample extens Activity
{
@Override
public void onCreate(Bundle SavedInstanceState)
{
super.onCreate(SavedInstanceState);
setContentview(R.layout.image);
Fresco.initialize(this);
//setting the image 
Uri uri=Uri.parse("http://image_url");
SimpleDreeView view=(SimpleDreeView)findViewById(R.id.image);
view.setImageURI(uri);
}
}

sumankumar80

Hello Friends,I have written and developed this website because you can learn technology easily ,prepare for the placement and also for the any type of examination . By :Suman Kumar

Leave a Reply

Your email address will not be published. Required fields are marked *