-->

如何在黑莓应用程序安装备选入口点?如何在黑莓应用程序安装备选入口点?(How to setup al

2019-05-12 13:19发布

如何在黑莓Application.There设置备用入口点为2的应用

  1. UI应用
  2. 后台应用程序:将在自动启动运行。

有一个黑莓知识中心文章关于这一点,我试过了,编码如下。 但在点击应用程序图标,没有任何反应。

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 (编辑)无效链接
任何机构可以帮助,我要去错在何处。

Answer 1:

尝试登录args来价值(如果不为null)ARGS [0],看看有什么实际上正在进入主()。 很可能与在后台模块没有传递参数(或不经过正确的值)的编制过程中的问题。

此外,尝试你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();         
         } 
       }        
    }   
}


文章来源: How to setup alternate entry point in Blackberry application?