简体   繁体   English

如何在Blackberry应用程序中设置备用入口点?

[英]How to setup alternate entry point in Blackberry application?

How to setup alternate entrypoint in Blackberry Application.There will be 2 application 如何在Blackberry Application中设置备用入口点。将有2个应用程序

  1. UI Application UI应用程序
  2. Background Application: will run on autostart. 后台应用程序:将在自动启动上运行。

There is a blackberry knowledge center article about this, which I tried, and coded as follows. 有一个关于这个的黑莓知识中心文章 ,我试过,编码如下。 But on clicking the application icon, there is no response. 但是在单击应用程序图标时,没有响应。

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();         
       }        
    }   
}

Class UI Application 类UI应用程序

class GUIApplication extends MainScreen {   
    public GUIApplication(){        
        add(new LabelField("Hello World"));             
    } 
}

Background Application 背景应用

class BackgroundApplication extends Application {   
    public BackgroundApplication() {
        // TODO Auto-generated constructor stub
    }
    public void setupBackgroundApplication(){

    }   
}

I configured Blackberry_App_Discriptor.xml according to this (edit) bad-link 我根据这个(编辑)坏链接配置了Blackberry_App_Discriptor.xml
Can any body help,where am going wrong. 任何身体都可以帮助,哪里出错了。

Try logging the value of args and (if not null) args[0] to see what's actually being passed into main(). 尝试记录args的值和(如果不是null)args [0]以查看实际传递给main()的内容。 It's likely a problem with your compilation process where the background module is not passing an argument (or not passing the correct value). 您的编译过程可能存在问题,即后台模块未传递参数(或未传递正确的值)。

Also, try saving off your EntryPointForApplication instance into a static variable so that it maintains a reference (isn't garbage collected) and so that if the icon is clicked again from the home screen while it's already running, you don't start multiple instances of your app. 另外,尝试将EntryPointForApplication实例保存到静态变量中,以便维护引用(不是垃圾回收),这样如果在主屏幕已经运行时再次单击该图标,则不会启动多个实例你的应用程序。 For example: 例如:

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();         
         } 
       }        
    }   
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM