jeudi 9 avril 2015

OutOfMemory error, and no idea how to set up bitmaps

Sorry if this Question is a bit obvious, but I've created an app, which contains a bunch of customized buttons on the MainScreen. In the beginning, everything worked fine, but then, I've made something, no idea what, unfortunately I've forgotten what I've done. But now, Im getting this annoying OutOfMemory error, and as I'm not that pro in programming, I'm stuck now in fixing this. I've tried setting up Managing Bitmap Memory, also downloaded the Sample App, but I got lost in there, i didnt even found something that looked like a mainscreen.


I've tried to put this code fom the developer site in my MainScreen.java, but I think this is not the way it works:



if (Utils.hasHoneycomb()) {
mReusableBitmaps =
Collections.synchronizedSet(new HashSet<SoftReference<Bitmap>>());
}

mMemoryCache = new LruCache<String, BitmapDrawable>(mCacheParams.memCacheSize) {

// Notify the removed entry that is no longer being cached.
@Override
protected void entryRemoved(boolean evicted, String key,
BitmapDrawable oldValue, BitmapDrawable newValue) {
if (RecyclingBitmapDrawable.class.isInstance(oldValue)) {
// The removed entry is a recycling drawable, so notify it
// that it has been removed from the memory cache.
((RecyclingBitmapDrawable) oldValue).setIsCached(false);
} else {
// The removed entry is a standard BitmapDrawable.
if (Utils.hasHoneycomb()) {
// We're running on Honeycomb or later, so add the bitmap
// to a SoftReference set for possible use with inBitmap later.
mReusableBitmaps.add
(new SoftReference<Bitmap>(oldValue.getBitmap()));
}
}
}



};


I have just putted all my Pictures of the buttons and so on in my res/drawable folder, as you can see here: (is this correct if i want to do that bitmap stuff?)



I would be happy if someone could help me, I'm stuck for like 3 hours on this problem.


Aucun commentaire:

Enregistrer un commentaire