title: How to cache images in intent service (background thread) using Universal Image Loader
body: <p>I am testing upgrading to use Android Universal Image Loader 1.9.0.  I have tested this on Android 4.2.  I've come across a problem where I am downloading and caching images in an intent service to be run on a background thread to not interfere with the user.  However, UIL is complaining that I am not loading these images on the main thread.  I don't want to load these images on the main thread, I just want to be able to cache them on disc in the background so that they don't need to be downloaded when the user actually views the specified images.  Is there another way to pre-cache the images on a background thread besides ImageLoader.loadImage?  If not, how do I allow pre-caching on disc on a thread that isn't the main thread?  All of this code is being run in an IntentService.</p>
  
  <p>ImageLoaderConfiguration: </p>
  
  <pre><code>ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
              getApplicationContext())
              .threadPriority(Thread.MAX_PRIORITY)
              .memoryCacheSize(memoryCacheSize)
              .denyCacheImageMultipleSizesInMemory()
              .threadPoolSize(5)
              .discCacheFileNameGenerator(new MyFileNameGenerator())
              .tasksProcessingOrder(QueueProcessingType.LIFO)
              .build();
  </code></pre>
  
  <p>DisplayImageOptions:</p>
  
  <pre><code> DisplayImageOptions options = new DisplayImageOptions.Builder().cacheOnDisc()
                  .imageScaleType(ImageScaleType.NONE).build();
  </code></pre>
  
  <p>Load image code:</p>
  
  <pre><code>imageLoader.loadImage(imageURI, options,
              new SimpleImageLoadingListener() {
                  @Override
                  public void onLoadingComplete(String imageUri, View view,
                          Bitmap loadedImage)
                  {
                      loadNext();  // gives a notification update and loads next image URI in queue
                  }
  
                  @Override
                  public void onLoadingFailed(String imageUri, View view,
                          FailReason failReason)
                  {
                      loadNext(); // gives a notification update and loads next image URI in queue
                  }
              });
  </code></pre>