0

I am building an android application. It contains total ten activities. All activities are build for portrait mode. Requirement is that in landscape mode of all the activities, same coverflow effect should be displayed. We can do that through onConfigChange method, but the problem is that in implementing a coverflow effect everytime consumes a lot of memory and system gets crashed. Might be somewhere memory leak problem.

So, i am wondering that is there any simple technique, so that system does not get crashed and have smooth orientation?

Thank you.

user609239
  • 3,356
  • 5
  • 25
  • 26

1 Answers1

1

Preventing memory leaks is an approach to building your app. It's simple when you know it: http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.html

In a nutshell:

  1. Don't hold on to Views and Drawables. This prevents GC to dispose of Activities.
  2. Don't decode Bitmaps on every orientation change. Decode them once and then save them in your custom Application class (which is one per app and does not get destroyed on orientation change). You could also make custom image cache class.
  3. Load images in their target resolution (resize when decoded) with inSampleSize option:

    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inSampleSize = 8;
    Bitmap bitmap=BitmapFactory.decodeStream(inStream,null,options);
    
Community
  • 1
  • 1
Peter Knego
  • 79,991
  • 11
  • 123
  • 154