-2

I am reciving a nullpointerexpression when I try to get a Bitmap.

ImageLoader imageLoader = ImageLoader.getInstance();
Bitmap bmp = null;
bmp = imageLoader.loadImageSync("http://i.imgur.com/tx41HBE.jpg");

The bmp variable is null after calling the imageLoader.loadImageSync() method , what's the reason?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
siemaeniu500
  • 115
  • 1
  • 9

1 Answers1

0

Try this

private ImageLoader imageLoader;
  private ImageLoaderConfiguration config;
config = new ImageLoaderConfiguration.Builder(this)
    .threadPriority(Thread.NORM_PRIORITY - 2)
    .denyCacheImageMultipleSizesInMemory()
    .diskCacheFileNameGenerator(new Md5FileNameGenerator())
    .diskCacheSize(50 * 1024 * 1024) // 50 Mb
    .tasksProcessingOrder(QueueProcessingType.LIFO)
    .writeDebugLogs() // Remove for release app
    .build();
imageLoader =  ImageLoader.getInstance();
imageLoader.init(config);
Bitmap bmp = null;
                    bmp = imageLoader.loadImageSync("http://i.imgur.com/tx41HBE.jpg");

The reason might be that you didn't initialize the imageLoader using imageLoader.init(config)

Abhriya Roy
  • 1,338
  • 17
  • 23