# Universal Image Loader

# Basic usage

  • Load an image, decode it into a bitmap, and display the bitmap in an `ImageView` (or any other view which implements the `ImageAware` interface):
    ImageLoader.getInstance().displayImage(imageUri, imageView);
    
    
  • Load an image, decode it into a bitmap, and return the bitmap to a callback:
    ImageLoader.getInstance().loadImage(imageUri, new SimpleImageLoadingListener() {
        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            // Do whatever you want with the bitmap.
        }
    });
    
    
  • Load an image, decode it into a bitmap and return the bitmap synchronously:
    Bitmap bmp = ImageLoader.getInstance().loadImageSync(imageUri);
    
    
  • # Initialize Universal Image Loader

  • Add the following dependency to the **build.gradle** file:
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    
    
  • Add the following permissions to the **AndroidManifest.xml** file:
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
    
  • Initialize the Universal Image Loader. This must be done before the first usage:
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
        // ...
        .build();
    ImageLoader.getInstance().init(config);
    
    

    The full configuration options can be found here (opens new window).

  • # Remarks

    Acceptable URI examples:

    "http://www.example.com/image.png" // from Web
    "file:///mnt/sdcard/image.png" // from SD card
    "file:///mnt/sdcard/video.mp4" // from SD card (video thumbnail)
    "content://media/external/images/media/13" // from content provider
    "content://media/external/video/media/13" // from content provider (video thumbnail)
    "assets://image.png" // from assets
    "drawable://" + R.drawable.img // from drawables (non-9patch images)