开发者

Using CodeModuleListener + Blackberry

I am trying to use CodeModuleListener in my application. I am testing this on simulator. After I run my application I add another cod file to the simulator but the moduleAdded(..) method of CodeModuleListener is not called, when I expect it would be.

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);          
                    //writeFi开发者_Go百科le(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());              
             }
         });
    }


Add listener before the theApp.enterEventDispatcher(); call.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜