May You solve the problem by loading images Asychronously.
May You solve the problem by loading images Asychronously Use this code to set the images AsyncImageLoaderv asyncImageLoaderv=new AsyncImageLoaderv(); Bitmap cachedImage = asyncImageLoaderv. LoadDrawable(imgurl, new AsyncImageLoaderv.ImageCallback() { public void imageLoaded(Bitmap imageDrawable, String imageUrl) { if(String. ValueOf(imageDrawable).
Equals("null")){} else{ img. SetImageBitmap(imageDrawable); } } }); img. SetImageBitmap(cachedImage); The AsyncImageLoaderv Class is Here import java.io.
FilterInputStream; import java.io. IOException; import java.io. InputStream; import java.lang.ref.
SoftReference; import java.net. URL; import java.util. HashMap; import android.graphics.
Bitmap; import android.graphics. BitmapFactory; import android.os. Handler; import android.os.
Message; import android.util. Log; public class AsyncImageLoaderv { private HashMap> imageCache; public AsyncImageLoaderv() { imageCache = new HashMap>(); } public Bitmap loadDrawable(final String imageUrl, final ImageCallback imageCallback) { if (imageCache. ContainsKey(imageUrl)) { SoftReference softReference = imageCache.
Get(imageUrl); Bitmap drawable = softReference.get(); if (drawable! = null) { return drawable; } } final Handler handler = new Handler() { @Override public void handleMessage(Message message) { imageCallback. ImageLoaded((Bitmap) message.
Obj, imageUrl); } }; new Thread() { @Override public void run() { try{ Log. D("ur",imageUrl); Bitmap drawable = loadImageFromUrl(imageUrl); imageCache. Put(imageUrl, new SoftReference(drawable)); Message message = handler.
ObtainMessage(0, drawable); handler. SendMessage(message); }catch(Exception e){Log. E("thread stellent",e.toString());} } }.start(); return null; } public static Bitmap loadImageFromUrl(String url) { InputStream inputStream;Bitmap b; try { inputStream = (InputStream) new URL(url).getContent(); BitmapFactory.
Options bpo=new BitmapFactory.Options(); bpo. InSampleSize=2; //b=BitmapFactory. DecodeStream(inputStream, null,bpo ); PatchInputStream patch=new PatchInputStream(inputStream); b=BitmapFactory.
DecodeStream(patch); return b; } catch (IOException e) { throw new RuntimeException(e); } //return null; } public interface ImageCallback { public void imageLoaded(Bitmap imageBitmap, String imageUrl); } } class PatchInputStream extends FilterInputStream { public PatchInputStream(InputStream in) { super(in); } public long skip(long n) throws IOException { long m = 0L; while (m.
Thanks for your suggestion. The problem wasn't in the loading, but rather the fact that the images were all loaded into the heap. I solved the problem by using a Gallery View, which is almost as good as my previous solution, but is much, much better in regards of memory.
– Michell Bak Jul 30 at 8:20.
It seemed like there was no way to lower the memory used by the ARGB888 bitmaps, so I decided to use a Gallery View instead of the ScrollView. This is a lot better for memory management. For those of you wondering why I didn't just go ahead and do this in the first place - well, the ScrollView looks cooler in my opinion and I'm not that fond of the whole center aligning of the Gallery View, but I'll live with it.
Thanks!
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.