开发者

How can run background service application and UIApplication same time

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.

Actually i 开发者_如何学Goam confuse in how call or start background service in Event Thread.


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 }
     }
}


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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜