开发者

Android: Same landscape view to all the activities of an application

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.


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);
    
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜