title: Loading bitmaps in onCreate makes activity start slow
body: <p>I'm new to android programming and recently been learning to develop some applications. It wasn't much problem until I came across dealing with images. I'm trying to develop a simple application more like a eBook which shows pictures(JPEG/PNG) stored in the drawable folder.</p>
  
  <p>My first approach was to use the Gallery widget, but I was unable to implement a proper zoom with that. So I'm now using a simple Imageview to display a single bitmap at a time and change or zoom the bitmap on touch events. In order to do that, I had to decode all the bitmaps into a bitmap array during activity startup so that i could use them anytime.</p>
  
  <p>My application starts fine on my Galaxy Tab but every phone except that takes about 3-5 seconds to start. I just wanted to know if there's an easy way to load bitmaps during start. Forgive me if my question is asked already, but I searched stackoverflow a lot and couldn't find specific answer to my question. Here's my code. Hope anyone could help.</p>
  
  <pre><code>    package ....
  
      imports ....
  
      public class ImageViewFlipper extends Activity {
  
      private ViewFlipper viewFlipper;
      private Bitmap[] bMap= new Bitmap[15];
      private TextView currentpage;
      private ImageViewZoom iv;
      private imagenum=3;
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.main);
      bMap[0] =BitmapFactory.decodeResource(getResources(), R.drawable.page);
      bMap[1] =BitmapFactory.decodeResource(getResources(), R.drawable.page1);
      bMap[2] =BitmapFactory.decodeResource(getResources(), R.drawable.page10);
      bMap[3] =BitmapFactory.decodeResource(getResources(), R.drawable.page11);
      bMap[4] =BitmapFactory.decodeResource(getResources(), R.drawable.page12);
      bMap[5] =BitmapFactory.decodeResource(getResources(), R.drawable.page13);
      bMap[6] =BitmapFactory.decodeResource(getResources(), R.drawable.page14);
      bMap[7] =BitmapFactory.decodeResource(getResources(), R.drawable.page2);
      bMap[8] =BitmapFactory.decodeResource(getResources(), R.drawable.page3);
      bMap[9] =BitmapFactory.decodeResource(getResources(), R.drawable.page4);
      bMap[10] =BitmapFactory.decodeResource(getResources(), R.drawable.page5);
      bMap[11] =BitmapFactory.decodeResource(getResources(), R.drawable.page6);
      bMap[12] =BitmapFactory.decodeResource(getResources(), R.drawable.page7);
      bMap[13] =BitmapFactory.decodeResource(getResources(), R.drawable.page8);
      bMap[14] =BitmapFactory.decodeResource(getResources(), R.drawable.page9);
  
      currentpage=(TextView)findViewById(R.id.textview);
      iv = (ImageViewZoom) findViewById(R.id.zero);
      iv.setImageBitmapReset( bMap[imagenum], 0, true );
      viewFlipper = (ViewFlipper) findViewById(R.id.flipper);
      ......
  </code></pre>
  
  <p>the value of imagenum changes according to the onFling method, ImageViewZoom is the custom ImageView class. I hope this much  information is sufficient.</p>