如何在黑莓应用程序安装备选入口点? [英] How to setup alternate entry point in Blackberry application?

查看:173
本文介绍了如何在黑莓应用程序安装备选入口点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How to setup alternate entrypoint in Blackberry Application.There will be 2 application


  1. UI应用程序

  2. 后台应用程序:将自动启动运行

有一个<一个href=\"http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800901/How_To_-_Setup_an_alternate_entry_point_for_my_application.html?nodeid=800820&vernum=0\"相对=nofollow>这个黑莓知识中心文章,我试过了,如下codeD。但在点击应用程序图标,没有任何反应。

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

类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 href=\"http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800901/How_To_-_Setup_an_alternate_entry_point_for_my_application.html?nodeid=800820&vernum=0\"相对=nofollow>(编辑)坏链接
结果任何机构的帮助下,我在那里去错了。

I configured Blackberry_App_Discriptor.xml according to this (edit) bad-link
Can any body help,where am going wrong.

推荐答案

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

Try logging the value of args and (if not null) args[0] to see what's actually being passed into 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).

另外,尽量节省了你的EntryPointForApplication实例到一个静态变量,因此它保持一个参考(不收集的垃圾),因此,如果从主屏幕上再次点击该图标,而它已经运行,你不启动您的应用程序的多个实例。例如:

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

这篇关于如何在黑莓应用程序安装备选入口点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆