I am trying to get bitmap from a given URL for this I am using UIL Library. For some reason I am not able to fetch the Bitmap. Here is what I am trying out.
Initialized the variables:
private ImageLoader imageLoader;
private ImageLoaderConfiguration config;
And then have the config initialized with imageloader:
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.getInstance().init(config);
And then trying to get the image URL provided:
Bitmap bmp = imageLoader.loadImageSync(ImageUrl);
storing the bmp data into an array for further usage.
I am getting the following error:
Attempt to invoke virtual method 'android.graphics.Bitmap com.nostra13.universalimageloader.core.ImageLoader.loadImageSync(java.lang.String)' on a null object reference
I am not sure what could be wrong here? Can somebody help me fix this up?
Your imageLoader
is null because you didn't set it:
Try this:
imageLoader = ImageLoader.getInstance();
imageLoader.init(config);