How to find running application size programatically in blackberry?

前端 未结 1 2037
日久生厌
日久生厌 2020-12-22 08:05

i want to find the size of running application of blackberry by code.I checked the how to find application size in blackberry by code? link but i am not getting answer. Plea

相关标签:
1条回答
  • 2020-12-22 08:46

    If you mean of size of running application that size of total cod files then we can calculate.

    when we instal application using JAD we can see the application size.

    For example: my application name is PictureBackground

    After successful sign in application we can take cod fils and jad file for devise installation. when we click on PictureBackground.jad then we can find following type of information

    Name: PictureBackground

    Version: 1.0.0

    Vender: Blackberry Developer

    Size: 513.4kb

    If you want to pragmatically retrieve that size, then we can do it as following

    we can find all information about application in PictureBackground.jad file

    For example PictureBackground.jad file as follow:

    RIM-COD-SHA1-4: ff 3c 2f ec 7b 6a 3d 1a e3 86 ec d2 87 0a c3 e1 6c f3 14 0e
    RIM-COD-SHA1-3: 07 4d f7 db 9a f3 df 1d 00 90 b6 4f 54 f0 3a f0 c8 de ca b1
    RIM-COD-SHA1-2: 95 14 4a 6a 7d 3a 1b db 2e 0f 05 b8 e1 ff 66 8a e0 ce f1 64
    RIM-COD-SHA1-1: 68 a7 09 4e dc cf 2f c1 9b 43 d1 0b 35 b8 4b bc 35 72 ba 92
    RIM-MIDlet-Flags-1: 0
    MIDlet-Jar-Size: 591513
    MIDlet-Name: PictureBackground
    MIDlet-Jar-URL: PictureBackground.jar
    MicroEdition-Configuration: CLDC-1.1
    RIM-COD-URL-9: PictureBackground-9.cod
    RIM-COD-URL-8: PictureBackground-8.cod
    RIM-COD-URL-7: PictureBackground-7.cod
    RIM-COD-Module-Dependencies: net_rim_cldc
    RIM-COD-URL-6: PictureBackground-6.cod
    RIM-COD-URL-5: PictureBackground-5.cod
    RIM-COD-URL-4: PictureBackground-4.cod
    RIM-COD-URL-3: PictureBackground-3.cod
    RIM-COD-URL-2: PictureBackground-2.cod
    RIM-COD-URL-1: PictureBackground-1.cod
    RIM-COD-Size-9: 51288
    RIM-COD-Size-8: 55284
    RIM-COD-Size-7: 58560
    RIM-COD-Size-6: 51340
    RIM-COD-Size-5: 55748
    RIM-COD-Size-4: 53000
    RIM-COD-Size-3: 55084
    RIM-COD-Module-Name: PictureBackground
    RIM-COD-Size-2: 51284
    RIM-COD-Size-1: 60448
    RIM-COD-SHA1: 55 82 db c2 8c 44 73 c8 44 b6 ce 7f 20 bb 70 47 d2 df fe ab
    RIM-COD-Size: 33688
    MicroEdition-Profile: MIDP-2.0
    MIDlet-Vendor: BlackBerry Developer
    MIDlet-1: PictureBackground,,
    RIM-COD-URL: PictureBackground.cod
    Manifest-Version: 1.0
    MIDlet-Version: 1.0.0
    RIM-COD-SHA1-9: 76 04 75 59 21 27 c6 18 97 ed 49 fb ce 03 f3 21 fd 63 c1 96
    RIM-COD-SHA1-8: 79 a9 b7 85 59 aa 06 e6 4b 76 89 de 12 cd 10 0d 54 93 48 dd
    RIM-COD-SHA1-7: 3d d1 d1 47 e3 8d b5 9d 57 89 51 e3 a9 b3 77 5e c4 57 17 a8
    RIM-COD-Creation-Time: 1327931490
    RIM-COD-SHA1-6: f7 78 f7 b3 46 f5 69 91 9d 87 33 d0 a9 9d 9b 92 b6 de 90 74
    RIM-COD-SHA1-5: 98 b3 45 64 8b 5f 36 0a aa c1 0e 2e 66 ea 7a f7 50 37 05 7a
    

    Through this we can find the running application size Sample code :

     package samplecode;
    
    import java.util.Enumeration;
    
    import net.rim.device.api.system.ApplicationDescriptor;
    import net.rim.device.api.system.CodeModuleGroup;
    import net.rim.device.api.system.CodeModuleGroupManager;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.MainScreen;
    
    public class StartUp extends UiApplication{
        public static void main(String[] args) {
            StartUp up=new StartUp();
            up.enterEventDispatcher();
        }
        public StartUp()
        {
            MainScreen screen=new MainScreen();
             CodeModuleGroup cmg = null;
                CodeModuleGroup[] allGroups = CodeModuleGroupManager.loadAll();
                String moduleName = ApplicationDescriptor.currentApplicationDescriptor().getModuleName();
                for (int i = 0; i < allGroups.length; i++) {
                   if (allGroups[i].containsModule(moduleName)) {
                       cmg = allGroups[i];
                      break;
                     }
                }
                if (cmg == null) {
                    screen.add(new LabelField("not able to fetch properties"));
                } else {
                    double size=0;
                    for (Enumeration e = cmg.getPropertyNames(); e
                            .hasMoreElements();) {
                        String name = (String) e.nextElement();
                        String value = cmg.getProperty(name);
    
                        if(name.indexOf("RIM-COD-Size")!=-1)
                        {
                            size=size+Double.parseDouble(value);
                        }
                        //add(new LabelField("Name: " + name));
    
                    }
                    screen.add(new LabelField("Size: " +(size/1024)+"kb"));
                }
            UiApplication.getUiApplication().pushScreen(screen);
    
        }
    
    }
    

    NOTE: IT WONT WORK ON SIMULATOR, IT WORKS ON DEVISE(IT SHOULD BE INSTALL FROM JAD FILE) AND WE CAN FIND OUTPUT AS FOLLOWING

    size:513.40234375KB
    
    0 讨论(0)
提交回复
热议问题