Search code examples
androidhttp-status-code-404universal-image-loader

Universal Image Loader - Image URL 404 Error handling


I am trying to use the Android Universal Image Loader library to download images from a URL from the web. However, the URLs can return a 404 error because the picture sometimes hasn't been uploaded by the company. How do I handle this? I tried using the following but it had no effect:

DisplayImageOoptions options = new DisplayImageOptions.Builder()
  .cacheInMemory()
  .showImageForEmptyUri(R.drawable.no_image)
  .build();

Can someone please help me out and point me in the right direction? I would appreciate it very much.


Solution

  • You could try to use:

    DisplayImageOoptions options = new    DisplayImageOptions.Builder().
    cacheInMemory().
    showImageOnFail(R.drawable.no_image).
    showImageForEmptyUri(R.drawable.no_image).
    build();