如何在黑莓中以编程方式查找运行的应用程序大小?

时间:2012-01-30 08:17:19

标签: blackberry filesize

我想通过代码找到运行黑莓应用程序的大小。我检查了how to find application size in blackberry by code?链接,但我没有得到答案。请建议我解决方案。提前谢谢。

1 个答案:

答案 0 :(得分:0)

如果您指的是正在运行的应用程序的大小 总鳕鱼文件的大小 然后我们可以计算出来。

当我们使用JAD安装应用程序时,我们可以看到应用程序的大小。

例如:我的应用程序名称是 PictureBackground

成功登录申请后,我们可以使用cod fils和jad文件进行设计安装。当我们点击PictureBackground.jad然后我们可以找到以下类型的信息

名称: PictureBackground

版本: 1.0.0

Vender: Blackberry Developer

大小: 513.4kb

如果您想以实用方式检索该大小,那么我们可以按照以下方式执行此操作

我们可以在PictureBackground.jad文件中找到有关应用程序的所有信息

例如PictureBackground.jad文件如下:

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

通过此,我们可以找到正在运行的应用程序大小  示例代码:

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

    }

}

注意:它在模拟器上运行,它在设备上工作(它应该从JAD文件安装),我们可以按以下方式查找输出

size:513.40234375KB