I think you are using the Google image search URL, which it defintely will take more time to read. That image actual link is I mentioned below..use this direct link instead so it will load faster/better.
because it may take three or request in Google but it's a direct link for that file that's the reason....
http://upload.wikimedia.org/wikipedia/commons/7/7a/Basketball.png
And then use like this methods to read the images from Url.....
public static class BitmapWorkerTask extends
AsyncTask<String, Void, Bitmap> {
private int ht;
private int wt;
// Decode image in background.
public BitmapWorkerTask(int progress, int ht, int wt) {
this.ht = ht;
this.wt = wt;
}
@Override
protected Bitmap doInBackground(String... params) {
URL url;
try {
url = new URL(string);
if (getBitmapFromMemCache(position) == null) {
HttpURLConnection connection = (HttpURLConnection) url
.openConnection();
connection.setConnectTimeout(4000);
connection.setReadTimeout(10000);
int v = connection.getContentLength() > 0 ? connection
.getContentLength() : 0;
if (v > 0) {
InputStream in = new BufferedInputStream(
connection.getInputStream(), 32 * 1024);
Bitmap bitmap = decodeSampledBitmapFromResource(
in, ht[i], wt[i]);
} catch (MalformedURLException e) {
// e.printStackTrace();
} catch (IOException e) {
// e.printStackTrace();
}
}
return bitmap ;
}
@Override
protected void onPostExecute(Bitmap result) {
//Do your bitmap image setting....
//image.setImageBitmap(bitmap);
}
}
And this below methods are used to avoid the Out of memory exception....This will useful for you in high processing with images that's all...
public static Bitmap decodeSampledBitmapFromResource(InputStream in,
int reqWidth, int reqHeight) throws IOException {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
in.mark(in.available());
BitmapFactory.decodeStream(in, null, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth,
reqHeight);
in.reset();
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeStream(in, null, options);
}
public static int calculateInSampleSize(BitmapFactory.Options options,
int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
final int halfHeight = height / 2;
final int halfWidth = width / 2;
// Calculate the largest inSampleSize value that is a power of 2 and
// keeps both
// height and width larger than the requested height and width.
while ((halfHeight / inSampleSize) > reqHeight
&& (halfWidth / inSampleSize) > reqWidth) {
inSampleSize *= 2;
}
}
return inSampleSize;
}