Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 190
Registered: ‎07-08-2009
My Device: Not Specified
Accepted Solution

Using CodeModuleListener

[ Edited ]

I am trying to use CodeModuleListener in my application. I am using it as :

public static void main(String[] args) {
        Application_Load theApp = new Application_Load();
        theApp.enterEventDispatcher();

           try 
              {
                   CodeModuleManager.addListener(UiApplication.getApplication(), cmListener);
              } 
              catch (NullPointerException e) 
              {
                   System.out.println(e.getMessage());
                   e.printStackTrace();
              } 
}


public Application_Load()
    {
     cmListener = new CodeModuleListener() 
           {

                public void modulesDeleted(String[] moduleNames) 
                {
                    String s = "APP DELETED ====================>";
                    System.out.println(s);          
                    //writeFile(s, "file:///SDCard/uploadedfile.txt");
                    deleteFile("file:///system/databases/TestApp/TestDB.db");
                }

                public void modulesAdded(int[] handles) 
                {
                    String s = "APP ADDED ====================>";
                    System.out.println(s);          
                    //writeFile(s, "file:///SDCard/uploadedfile.txt");
                    deleteFile("file:///system/databases/TestApp/TestDB.db");
                }

                public void moduleDeletionsPending(String[] moduleNames) 
                {
                    String s = "APP IS DELETING ====================>";
                    System.out.println(s);          
                    //writeFile(s, "file:///SDCard/uploadedfile.txt");
                    deleteFile("file:///system/databases/TestApp/TestDB.db");
                }
           };

        UiApplication.getUiApplication().invokeLater(new Runnable(){
             public void run() {
                 UiApplication.getUiApplication().pushScreen(new TestScreen());              
             }
         });
    }

I am testing this on simulator. After I run my application I add another cod file to the simulator but moduleAdded(..) method of CodeModuleListener is not called.

Please guide me if i am doing anything wrong here..

Highlighted
New Developer
Posts: 5
Registered: ‎01-23-2009
My Device: Not Specified

Re: Using CodeModuleListener

Try adding the listener before you enter the event dispatch loop since it doesn't return.