如何在Blackberry应用程序中设置备用入口点?
如何在Blackberry Application中设置备用入口点。将有2个应用程序
- UI应用程序
- 后台应用程序:将在自动启动上运行。
有一个关于这个的黑莓知识中心文章 ,我试过,编码如下。 但是在单击应用程序图标时,没有响应。
class EntryPointForApplication extends UiApplication { public EntryPointForApplication() { GUIApplication scr = new GUIApplication(); pushScreen(scr); } public static void main(String[] args) { if ( args != null && args.length > 0 && args[0].equals("background1") ){ // Keep this instance around for rendering // Notification dialogs. BackgroundApplication backApp=new BackgroundApplication(); backApp.enterEventDispatcher(); backApp.setupBackgroundApplication(); } else { // Start a new app instance for GUI operations. EntryPointForApplication application = new EntryPointForApplication(); application.enterEventDispatcher(); } } }
类UI应用程序
class GUIApplication extends MainScreen { public GUIApplication(){ add(new LabelField("Hello World")); } }
背景应用
class BackgroundApplication extends Application { public BackgroundApplication() { // TODO Auto-generated constructor stub } public void setupBackgroundApplication(){ } }
我根据这个(编辑)坏链接配置了Blackberry_App_Discriptor.xml
任何身体都可以帮助,哪里出错了。
尝试记录args的值和(如果不是null)args [0]以查看实际传递给main()的内容。 您的编译过程可能存在问题,即后台模块未传递参数(或未传递正确的值)。
此外,尝试将EntryPointForApplication实例保存到静态变量中,以便它维护一个引用(不是垃圾回收),这样如果在主屏幕已经运行时再次单击该图标,则不会启动多个实例你的应用程序。 例如:
class EntryPointForApplication extends UiApplication { private static EntryPointForApplication theApp; public EntryPointForApplication() { GUIApplication scr = new GUIApplication(); pushScreen(scr); } public static void main(String[] args) { if ( args != null && args.length > 0 && args[0].equals("background1") ){ // Keep this instance around for rendering // Notification dialogs. BackgroundApplication backApp=new BackgroundApplication(); backApp.setupBackgroundApplication(); backApp.enterEventDispatcher(); } else { if (theApp == null) { // Start a new app instance for GUI operations. theApp = new EntryPointForApplication(); theApp.enterEventDispatcher(); } } } }