Search code examples
blackberryblackberry-simulator

How to get package name using blackberry


I am new to blackberry development, Is it possible to get package name of the application which is installed in device. I din't get any reference for this.

 int[] handle = codeModuleManager.getModuleHandles();                    
        for(int i=0; i<handle.length; i++){  
            ApplicationDescriptor[] app_descriptors = CodeModuleManager.getApplicationDescriptors(handle[i]);               
                if(app_descriptors != null){ 
                    System.out.println("app_descriptors length "+ app_descriptors.length);   
                    for(int j=0; j< app_descriptors.length; j++){
                        System.out.println("Iterating the arraylist :: "+ app_descriptors[j].toString());
                    } 
                }               
        }      

Solution

  • Try this - This will get all the installed modules.

    int[] v=net.rim.device.api.system.CodeModuleManager.getModuleHandles();
    

    For getting the ApplicationDescriptors associated with the module, use the following code -

    net.rim.device.api.system.CodeModuleManager.getApplicationDescriptors(int moduleHandle)
    

    Edit : -

    int[] handle = CodeModuleManager.getModuleHandles();                    
        for(int i=0; i<handle.length; i++){  
            ApplicationDescriptor[] app_descriptors = CodeModuleManager.getApplicationDescriptors(handle[i]);               
                if(app_descriptors != null){ 
                    System.out.println("app_descriptors length "+ app_descriptors.length);   
                    for(int j=0; j< app_descriptors.length; j++){
                         String moduleName = app_descriptors[i].getModuleName();
                         String name = app_descriptors[i].getName();
    
    
                    } 
                }               
        }