How can run background service application and UIApplication same time

后端 未结 2 1669
南笙
南笙 2020-12-09 14:09

I want to run background service application and UIApplication same time.

Is it possible to create both in same project or need to create separate separate project.<

相关标签:
2条回答
  • 2020-12-09 14:53

    http://supportforums.blackberry.com/t5/Java-Development/Background-thread-for-push-notifications/td-p/563071

    the Blackberry dev forums are full of threads and sample code to accomplish this very thing.

    Personally, I use the alternate entry point method, run the background app as an autostart UiApplication (with no icon) that never pushes a MainScreen, but uses its own dispatch thread to throw up a dialog or similar notifications, and then when the actual Home Icon is pressed/clicked, I launch the Ui entry point to play with the user.

    0 讨论(0)
  • 2020-12-09 14:59

    This is how you can set up an alternate entry point for your application:

    A- Using the BlackBerry® Java® Plug-in for Eclipse®

    After creating the project for the original application, create an alternate entry point to launch the application UI.

    1- Double click on BlackBerry_App_Descriptor.xml within your project.
    2- Check off System Module and Do not display the application icon on the BlackBerry home screen.
    3-Click on the Alternate Entry Point tab.
    4- Click the Add button.
    5- Enter a title for the entry point and click OK.
    6- Specify the application argument that would launch the application using this alternate entry point (for example: gui).
    7- Proceed to the Common Steps section.
    8- Modify the main() method of the original project as follows:

    public static void main(String[] args) {
         if ( args != null && args.length > 0 && args[0].equals("gui") ){
              // code to initialize the app
              theApp.enterEventDispatcher();
         } else {
              // code to launch the background thread }
         }
    }
    



    B- Using the BlackBerry JDE

    After creating the projects for the original application, you will have to create another project for the UI entry point. Assuming that the thread to be run exists in the same project as the original application, follow these steps:

    1- Right-click the project node and select Properties.
    2- In the Properties window, select the Application tab.
    3- Verify the following options are checked: Auto-run on startup and System module (to register the thread with the system).
    4- Create another project under the same folder as the original project. Right-click the new project node and select Properties.
    5- Select the Application tab and select Alternate CLDC Application Entry Point from the Project type drop-down list. As shown in the attached file, select the name of the original project (for example, trafficreporter) from the Alternate entry point for drop-down list. Also specify the arguments that would launch the application using this alternate entry point (for example: gui). Proceed to the Common Steps section.
    6- Modify the main() method of the original project as follows:

    public static void main(String[] args) {
         if ( args != null && args.length > 0 && args[0].equals("gui") ){
              // code to initialize the app
              theApp.enterEventDispatcher();
         } else {
              // code to launch the background thread }
         }
    }
    
    0 讨论(0)
提交回复
热议问题