0

This troubled me for a long time...

I have a login screen with a background image to be setup. For avoid memory leak, I use the guide and code from google: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

And when it comes to jump to next activity, I put some recycle code into onPause of login activity to free the memory use of bitmap.

protected void onPause() {
    super.onPause();
    BitmapDrawable bd = (BitmapDrawable)background.getBackground();
    background.setBackgroundResource(0);
    bd.setCallback(null);
    bd.getBitmap().recycle();
}

This code doesn't create any error and from DDMS the bitmap is been freed.

But before the login screen disappear completely, it will be one second or two that the background is black. Other components of login screen are not gone yet, but the background will be gone first and left an ugly black...

Is there a way to solve this smoothly? Thank you!

Arthur Wang
  • 3,118
  • 4
  • 21
  • 29
  • dont know if it works but try using this link:http://stackoverflow.com/a/6468734/3110609 – Harshal Benake Feb 25 '14 at 08:45
  • Thanks for reply. I have tried that method before asking this question. But it seems not the solution of my case. When the BACKGROUND turned black, other UI are still there. So I think it is some thing I done with recycle the drawable resource of background in onPause. But I don't know how to avoid this happen. I tried to put that into onStop, but it still won't work. – Arthur Wang Feb 25 '14 at 09:50

0 Answers0