Search code examples
blackberrystartupimage-resizingperformance

Blackberry app is very slow on startup, how can i fix this?


I recently updated my app to work on nearly all of the phones. I did this by having the first screen detect the screen size and then change all the images (there are a lot of images). As such, the startup on the non-base model phones is like 15 seconds, it looks like the phone is freezing but its just changing the images. It does this every time I open the app. What can I do to fix this?


Solution

    • Make sure that you are resizing images on a separate thread (no UI Blocking operation).
    • It would be better if you store all the resized images on persistent storage so that you don't need to resize same image twice on a handset.

    [edited]

    Some links about how to use persistence storage:


    Sample Code Snippet for making a Bitmap object persistable:

    class PersistableBitmap implements Persistable {
        int width;
        int height;
        int[] argbData;
        
        public PersistableBitmap(Bitmap image) {
            width = image.getWidth();
            height = image.getHeight();
            argbData = new int[width * height];
            image.getARGB(argbData, 0, width, 0, 0, width, height);
        }
    
        public Bitmap getBitmapImage() {
            Bitmap image = new Bitmap(width, height);
            image.setARGB(argbData, 0, width, 0, 0, width, height);
            return image;
        }
    }