Search code examples
blackberryjava-mepush-notificationblackberry-jde

How to make a blackberry application start , by code?


I have a background function listening for push messages. I need to handle though the push. I created the function to take any actions when the push arrives and it works pretty well. For example when a push arrives i increment a number etc etc.

However what would be the code to actually make the application start , when the user presses ok to the push?

I just need to make the application start normally , like the user just pressed on the icon of the app.

I am using OS < 7.X

Solution

  • try this - When you click the ok button use the following code to run your ui application.

    public void dialogClosed(Dialog dialog, int choice) {
          switch (choice) {
              case Dialog.OK: 
                  try {
    
                      ApplicationDescriptor[] appDescriptors =CodeModuleManager.getApplicationDescriptors(CodeModuleManager.getModuleHandle("BlackBerryCity"));    //here BlackBerryCity is the COD module Name
                      ApplicationDescriptor appDescriptor = new ApplicationDescriptor(appDescriptors[0], new String[] {"BlackBerryCity"});
                      ApplicationManager.getApplicationManager().runApplication(appDescriptor);
    
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
    
                  break;
              case Dialog.CANCEL:
    
                  break;
              default:
                  break;
           }
       }