Issue of CodeModuleManager.getModuleName)

In the API, there are two signatures for this call: http://docs.blackberry.com/en/developers/deliverables/6022/net/rim/device/api/system/CodeModuleManag...

public static String getModuleName(int moduleHandle)
public static String getModuleName(int moduleHandle, int index)

Two of them take a moduleHandle object, but the other requires an index described as:

index - Ordinal in the name of the module in question.

What does "Ordinal to the name of the module in question"?

Thank you.

After a few hours of testing, I think that I thought about it.

CodeModuleManager.getModuleName (int moduleHandle):

Returns the name of the module with moduleHandle.

CodeModuleManager.getModuleName (int moduleHandle, int index):

Returns the length of the index'th of the moduleHandle in data object.

Here's the code I used to test:

       //Create an int array of all handles on the phone
                //True will return sibling Modules as well
                //False will return only "top level" modules
                int[] handles = CodeModuleManager.getModuleHandles(false);

                //Iterate through all module handles
        for (int i = 0; i < handles.length; i++) {
                        //Determine name of the Module
            String name = CodeModuleManager.getModuleName(handles[i]);

                        //For each name, print out identifying information in an
                        //easy to read format.
            System.out.println("[" + i + "] " + name + " :: " + handles[i]);

                        //Instantiate another counter at 1
                        //(Zero would just show the top level file again)
            int j = 1;

                        //Instantiate _name as the first dependent module
            String _name = CodeModuleManager.getModuleName(handles[i], j);

                        //Print the name of the Module
            System.out.println(_name);

                        //Begin iterating through all dependencies until null is reached.
                        //The Loop prints out the name, increments the counter "j", and
                        //gets the next dependency name.
            while(_name != null) {
                System.out.println("\t\t" + _name);
                j++;
                _name = CodeModuleManager.getModuleName(handles[i], j);
            }

                        //Reset the counter "j"
            j = 1;
        }

However, this does not correspond with the JavaLoader entry because it is by looking at only the dependencies for the module.cod > module.cod instead of high level "module.cod".

For a complete list of dependencies (or JavaLoader), you need to do the same for all the files of the siblings.

This code is as follows:

       // Create an int array of all handles on the phone
        // True will return sibling Modules as well
        // False will return only "top level" modules
        int[] handles = CodeModuleManager.getModuleHandles(true);

        // Iterate through all module handles
        for (int i = 0; i < handles.length; i++) {
            // Determine name of the Module
            String name = CodeModuleManager.getModuleName(handles[i]);

            // For each name, print out identifying information in an
            // easy to read format.
            System.out.println("[" + i + "] " + name + " :: " + handles[i]);

            // Instantiate another counter at 1
            // (Zero would just show the top level file again)
            int j = 1;

            // Instantiate _name as the first dependent module
            String _name = CodeModuleManager.getModuleName(handles[i], j);

            // Begin iterating through all dependencies until null is reached.
            // The Loop prints out the name, increments the counter "j", and
            // gets the next dependency name.
            while (_name != null) {
                System.out.println("\t\t" + _name);
                j++;
                _name = CodeModuleManager.getModuleName(handles[i], j);
            }

            // Reset the counter "j"
            j = 1;
        }

With a little massage, you can get data to resemble that of JavaLoader dir d s

Of all my tests, I was not able to reproduce the CMJ suggested output.

Tags: BlackBerry Developers

Similar Questions

  • COD installed via CodeModuleManager has "error checking".

    I searched the forums for all the threads on CodeModuleManager and creation of modules by program. I managed to gather enough information to get the code below, but it still does not have 100%. For brevity, I've deleted the error handling code.

    I can run my code below and it creates modules. I'm not trying to install over a previous installation, it comes to intall the app for the first time. However, the application that installs it will not work when I click on the application of the new icon (the app is signed). When I click on the newly installed application icon, I get this error message on the home screen (the application never starts). The message reads the following:

    Error at startup MyApp: Module 'MyApp' has verification errors.

    But if I reboot the device or the Simulator and click the icon of newly installed, it works without problem. The newly installed application has another point of entry that runs at startup which is for a process in the background in the application.

    When I try this code with a different and much smaller application that is just a simple file of COD it works and I can run the newly installed application immediately after installation.

    But when there are several cod brothers I noticed a few interesting releases in the debugger console. In the loop where I call CodeModuleManager.saveNewModule, I see the following output from the debugger

    CMM: Add MyApp (3972)
    AC: new CRC = 557
    CMM: Add MyApp-1 (4010)
    AC: new CRC = 558
    From level 7
    From MyApp
    Research installed codfiles alias "MyApp-2".
    Research uninstalled codfiles alias "MyApp-2".
    Module "MyApp-2' not found." Error at startup MyApp: Module ' MyApp-2' not found. "
    MIDlet PushRegistry startup
    MIDlet startup PushRegistry finished
    From net_rim_process_launcher
    Net_rim_process_launcher (156) started
    CMM: Add MyApp-2 (4013)
    AC: new CRC = 559

    Note that after that MyApp-1 is added that you see level 7 starts and triggers another startup auto entry point. But now MyApp-2 is not yet added, and he complains about not finding the MyApp-2 module.

    This message on MyApp-2 is related to me being able to run the newly installed application until I reboot? If not, is there any ideas on why I can't launch the new application immediately?

    String[] codUrls = new String[] {    "http://www.example.com/MyApp.cod,    "http://www.example.com/MyApp-1.cod,    "http://www.example.com/MyApp-2.cod ");
    
    CodeModuleGroup codeModuleGroup = new CodeModuleGroup("MyApp");codeModuleGroup.setCopyright("2009 MyCompany");codeModuleGroup.setDescription("MyApp for BlackBerry");codeModuleGroup.setVendor("MyCompany");codeModuleGroup.setVersion("1.0.0");
    
    //limit first module to 60KB since it must be under 64KB as mentioned in docsint firstModuleMaxSize = 1024 * 60;
    
    HttpConnection httpConn = null;InputStream inputStream = null;
    
    int[] newModuleHandles = new int[codUrls.length];
    
    for (int i = 0 ; i < codUrls.length ; i++){    httpConn = (HttpConnection) Connector.open(codUrls[i], Connector.READ_WRITE, true);    httpConn.setRequestMethod(HttpConnection.GET);    int responseCode = httpConn.getResponseCode();    if (responseCode == HttpConnection.HTTP_OK)    {        int responseLength = (int) httpConn.getLength();        byte[] responseBytes = new byte[responseLength];        int bytesRead = inputStream.read(responseBytes); intputStream.close(); httpConn.close();        if (bytesRead > firstModuleMaxSize)        {            //write the first part            newModuleHandles[i] = CodeModuleManager.createNewModule(bytesRead, responseBytes, firstModuleMaxSize);            //write the rest            CodeModuleManager.writeNewModule(newModuleHandles[i], firstModuleMaxSize, responseBytes, firstModuleMaxSize, bytesRead - firstModuleMaxSize);        }        else        {     //less than 60KB so write it all in one module            newModuleHandles[i] = CodeModuleManager.createNewModule(bytesRead, responseBytes, bytesRead);        }    }}
    
    for (int i = 0 ; i < codUrls.length ; i++){    if (newModuleHandles[i] != 0)    {        CodeModuleManager.saveNewModule(newModuleHandles[i], true);    }}
    
    for (int i = 0 ; i < codUrls.length ; i++){    if (newModuleHandles[i] != 0)    {        String modName = CodeModuleManager.getModuleName(newModuleHandles[i]);        System.out.println("adding module " + modName);    codeModuleGroup.addModule(modName);    }}
    
    codeModuleGroup.store();
    

    It does not work because you are breaking modules in parties to the arbitrary limit (64 k) and then recording these pieces using the CodeModuleManager API as if they were modules.

    Things to keep in mind:

    * A COD file can contain one or more modules. If it contains several modules, then the COD file is just a ZIP file without compression and each module is a file entry in the ZIP file.

    * The CodeModuleManager API works on modules instead of COD files.

    Therefore, you need to need to get the COD modules or files and stream then one by one and without breaking any which module to pieces at CodeModuleManager. You could achieve this by ensuring that you download are simple-module-COD-files (e.g., unpack the composite cod on the web server), or you can download a COD file and then unzip it into modules on the device (uses more memory).

    PS You are unable to read the entry correctly HTTP: method (byte []) read from the input stream only is not guaranteed to read all the data that you have asked, so, on top of the arbitrary question above with modules into pieces, you couldn't even read the modules in its entirety. You will need to loop until you have read everything you wanted, or until the input stream is closed prematurely.

  • How to get my application attributes?

    Hello

    I want to get my application of attributes such as vendor, Version, title, and Description. And all that stuff to display on the screen inside my application. How can I get my application attributes? Code snippets?

    Best regards.

    // Retrieve a handle for a module.
     int handle = CodeModuleManager.getModuleHandle("test_module");
    
     // Retrieve specific information about a module.
     String name = CodeModuleManager.getModuleName( handle );
     String vendor = CodeModuleManager.getModuleVendor( handle );
     String description = CodeModuleManager.getModuleDescription( handle );
     int version = CodeModuleManager.getModuleVersion( handle );
     int size = CodeModuleManager.getModuleCodeSize( handle );
     int timestamp = CodeModuleManager.getModuleTimestamp( handle );
    
     // Retrieve an array of handles for existing modules on a BlackBerry device
     int handles[] = CodeModuleManager.getModuleHandles();
    
  • replace the evaluation version of the application

    Hello

    Is there a method for my App_A, when installed, replace or remove App_B?  Assuming that the application names are different and different applications.

    Thank you

    Dan

    I'm missing something here...

    CodeModuleManager.getModuleHandles (), will give you a list of the module handles (Int'l table).

    CodeModuleManager.getModuleName (int) for each of the ints returned in the previous list, will give you the name of the module.

    CodeModuleManager.getApplicationDescriptors (int) you will get ads.

    Isn't what you want?

  • Version of the application

    Hi, Expert

    I'm building a request which version 1.0, next time I'll create the other version 2.0,.

    My question is how do I know the version of each on my code?

    Thank you

    // Retrieve a handle for a module. int handle = CodeModuleManager.getModuleHandle("test_module");
    
     // Retrieve specific information about a module. String name = CodeModuleManager.getModuleName( handle ); String vendor = CodeModuleManager.getModuleVendor( handle ); String description = CodeModuleManager.getModuleDescription( handle ); int version = CodeModuleManager.getModuleVersion( handle ); int size = CodeModuleManager.getModuleCodeSize( handle ); int timestamp = CodeModuleManager.getModuleTimestamp( handle );
    

    This might help you

  • Missing cod and strange Module name

    I could use some ideas on a strange problem, when you use the (3.4.2) Eclipse Plugin.  In fact, I am able to use the Simulator to test and debug without a lot of questions.  However, when I try to move the code on a real device I see the Jad, among other things, merges.

    My name name / main module class is BPM.

    I have a code I use to get my internal module name:

    String name = CodeModuleManager.getModuleName (myModuleHandle);

    My application uses this to generate a header that displays while the BPM-1 ?

    Try an OTA, I find the Jad file points to BPM-1. Cod which does not exist.

    When you ask the key signature, he prays and sign a non-existent BPM - 1. Cod ?

    This is what looks like the output directory:

    Directory of C:\Users\....\BPM\0.2\BPM
    
    01/25/2010  05:29 PM              .
    01/25/2010  05:29 PM              ..
    01/25/2010  10:23 AM              .BlackBerryPreprocessed
    01/25/2010  04:24 PM               283 .classpath
    01/25/2010  10:23 AM               723 .project
    01/25/2010  04:30 PM              .settings
    01/25/2010  10:23 AM              .tmp
    01/25/2010  04:24 PM              bin
    01/25/2010  04:57 PM            49,156 BPM-1.debug
    01/25/2010  04:57 PM           123,498 BPM.cod
    01/25/2010  04:57 PM                26 BPM.csl
    01/25/2010  04:57 PM               157 BPM.cso
    01/25/2010  04:57 PM             4,674 BPM.debug
    01/25/2010  04:57 PM               900 BPM.jad
    01/25/2010  04:57 PM           239,400 BPM.jar
    01/25/2010  05:03 PM             1,706 BPM.jdp
    01/25/2010  04:51 PM               524 BPM.rapc
    01/25/2010  03:04 PM              src
    

    Any ideas would be appreciated.

    If your COD file exceeds 64K or 64K of data code, the compiler will generate 1 bpm, bpm-2, etc.

    These are "zipped" upward in a global file of COD.

    Rename your cod to the ZIP extension file, and then extract the contents. These individual COD files must be copied to your server deployment with the JAD file.

  • Appeal iPhone issues 7 more

    I recently bought the new iPhone 7 more.  Not only am I having problems with the LTE service, bounce back between 3 G and no service I am now having problems with call connectivity.  When you try to make an outgoing call, I get an automatic response from my carrier (Verizon) "it's Verizon, we are unable to complete your call at this time, please turn off your phone and back and try again."

    It is a known issue with the iPhone 7 and Verizon. Supposed to be Apple and Verizon are seeking him. It has been a problem since the phone was released. Do a Google search or search here on the forums for a temporary solution but not a cure.  But basically to stop the LTE oice and data into data only in the settings.

  • iPhone 6 more hang freeze issues

    My iPhone 6 more guard suspended (gel) for the past 6 months, I have to reset the whole phone sometimes up to 2 times just to get it to work again. Been a loyal (including my entire family) custome since gen 1 iPhone, iPad, mac book. Am really disappointed with the quality now. Did not bring to the service center since the first day of the problem because I thought that was just a few bugs & was sure that apple will fix it, but after many update of iOS so far, the pesisit still problem.

    iPhone is more quality I've known, hope apple can fix this problem before finally losing the most loyal customers

    Hello BennyFoo,

    Thank you for bringing your iPhone freeze questions here for Apple Support communities. I understand how it is important to have a reliable phone. I'm happy to check this with you.

    The first thing we want to make sure that all of your data on your device is safe. You can perform a backup in iCloud or iTunes using this article: backing up your iPhone, iPad, and iPod touch.

    Once your data is safe, try to turn off your device, then again on the March. Sometimes, that's all that is needed for connections reset and everything working properly again. This article help from Apple will help you to do: restart your iPad, iPhone or iPod touch. If you are still having issues, try force reset then. It is designed to be used when the iPhone does not respond, and it looks to be the exact symptoms that you are experiencing right now.

    If you still experience the same problems after reboot, please try to restore your device from a backup by using this article help: restore your iPhone, iPad or iPod touch from a backup. If you don't have a current backup, please try this help article: If you can not update or restore your iPhone, iPad, or iPod touch. Please pay close attention when you get to step 4 who said "when you see the option restore or put to update, choose update. iTunes will try to reinstall iOS without erasing your data. "to get your iOS reinstalled. Test if the issue is still ongoing.

    Thanks again and have a great rest of your day.

  • Pages on issues of formatting to iCloud

    Hey everybody,

    I created a document Pages using the Pages application on my macbook pro I downloaded then to iCloud Pages so that I can access it from any computer. The issue I'm having is that I formatted some of the text to have a black background and the text to yellow color. For the life of me I can't understand how to change the background color of text on the Pages of iCloud. I beginning to think that changing the background color of text just is not possible on the platform of iCloud, but wanted to put this out there just to make sure.

    I appreciate any help or clarification on this issue.

    Thank you!

    Background (highlight) text color controls are absent in the Pages for iCloud, because it is a subset of Pages for Mac.

    This has been discussed in a previous post here, not so long ago.

  • External hard drive mounting issues on MacOS Sierra

    After upgrading to OS Sierra, I found that my USB3 drives, directly connected to my iMac end of 2012, turn off at startup. USB 2 disks are unaffected and connect properly. The only way to access my USB3 disks is to disconnect and reconnect every time I start the computer, then they are ok. I tried to reset the NVRAM, but it did not work. I found Os El Capitan until this issue is resolved.

    Do not mount or actually turns out always the system start? It was not clear in your subject line and content later, what was going on.

    Are they NTFS formatted drives? See the solutions frequently asked and answered forum if they are.

  • TVos 10 - Apple TV 4 (Wifi issues)

    My apple TV was working until it was upgraded to the new update 10 TVos great. I reset my router and modem, reset the apple tv itself and it has restarted several times, all with the same mistake of not being able to connect to the wifi network. My iPhone and computer are connected properly, get about 40mbps is normal, and the router is in the same room. Everyone knows these issues? No luck, anyone know a fix?

    have you tried to restore the appletv? Restore your Apple TV via iTunes - Apple Support

  • I can't reach some websites with any browser. I get the message ERR_CONNECTION_REFUSED. If I boot in safe mode I don't have the issue. I tried the reset and repair of everything. Help, please

    I can't reach some websites with any browser. I get the message ERR_CONNECTION_REFUSED. If I boot in safe mode I don't have the issue. I tried the reset and repair of everything. Help, please

    Try to run this program in your usual account, then copy and paste the result in a response. The program was created by Etresoft, a regular contributor.  Use please copy and paste the screenshots can be difficult to read. On the screen with the Options, please open Options and tick the boxes in the bottom 2 before the race. Click on the button "Report share" in the toolbar, select "Copy to Clipboard" and then paste into a response. This will show what is running on your computer. No personal information is shown.

    Etrecheck - Information System

  • connectivity issues mobile iPhone 7

    I have a new iPhone 7 jet black, so far I'm in love. But yesterday, I noticed an annoying problem. The phone loses the network connection (cell to the & t) and he no reconnect, it will remain just it saying no service. I have to go in airplane mode and outside to force it to look for the network connection.

    everyone knows this? and everybody understand what it could be?

    I already missed messages and a phone call. This could worsen as boring to become a problem. If anyone has any idea what this could be please give me a heads up!

    OH! Another thing I noticed, when the iPhone is connected my signal strength went from-102 to my 6 sec to-86 on my 7! Then when I am connected I am connected!

    Hello jpgraphx,

    Thank you for using communities Support from Apple. I know have a cell connection issue on your new iPhone, it's not what you expect. The good news are the following steps will help to solve your problem with loss of cellular data and see no Service and get your new iPhone works properly again.

    If you cannot connect to a cellular network or cellular data

    See you soon!

  • Backup issues after upgrade to iOS10

    Dear users of Apple,

    I updated my iphone 6 more yesterday with iOS 10. Phone works quite well. But I have my phone backup problems. I usually back up my phone with my iTunes Macbook (Via cable and sometimes on wifi). But after the update to iOS 10 it seems that I can't back up my phone more. I don't know the real cause of this problem.

    1. I am not able to save my iPhone via wifi data in iTunes. (Previously it was not the case).

    2. I tried to back up my phone using the cable also. Also, I pressed "Trust" this computer, but I get this error message. Please see below.

    Also, I allowed my computer by disconnecting iTunes and logging back there. And yet I have the same issues.

    "iTunes could not connect to the iPhone because an invalid response was received from the device."

    Does anyone know what this answer is invalid can be?

    Do I have to change the settings in my phone or iTunes?

    Help please!

    Thank you very much

    Deven

    Did install you the latest iTunes? iOS 10 requires iTunes 12.5.1.

    Get the latest version of iTunes - Apple Support

  • A 2 month old iPod Touch 5th generation began to lose its charge the battery overnight.  East - the developer of a battery issue?

    A "renovated" old 2 months iPod Touch 5th generation just recently started losing its charge the battery during the night.  East - the developer of a battery issue?

    Perhaps. Where did you buy this device?

Maybe you are looking for