I have a scrollview with small thumbnails of images uploaded via AsyncTask, and it outputs the URL of the image to the image.
They are added dynamically, and then on top, this is the main image that holds the image of the thumbnail that you clicked.
Everything works fine until you have more than 10 images in the thumbnails ...
I load the mainImage url just like thumbnails, so when they click on the image in the thumb, it loads it up.
I recycle the bitmap in the method itself, but it seems to run out of memory and crash when loading more than 10 images (thumbnails load normally, but crash when clicking the button to load the main image)
any help appreciated
this is the code i use to upload images (thumbnails + main):
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> { ImageView bmImage; public DownloadImageTask(ImageView bmImage) { this.bmImage = bmImage; } protected Bitmap doInBackground(String... urls) { String urldisplay = urls[0]; Bitmap mIcon11 = null; try { InputStream in = new java.net.URL(urldisplay).openStream(); mIcon11 = BitmapFactory.decodeStream(in); } catch (Exception e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } return mIcon11; } protected void onPostExecute(Bitmap result) { bmImage.setImageBitmap(result); } }
sykal source share