gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 04:00:28 25 4
gpt4 key购买 nike

如何在黑莓应用程序中设置备用入口点。将有 2 个应用程序

  1. 用户界面应用
  2. 后台应用程序:将在自动启动时运行。

有一个blackberry knowledge center article关于这个,我试过,编码如下。但是点击应用程序图标,没有任何反应。

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(){

}
}

我根据这个(edit) bad-link配置了Blackberry_App_Discriptor.xml
任何人都可以帮忙吗,哪里出了问题。

最佳答案

尝试记录 args 和(如果不为空)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();
}
}
}
}

关于java - 如何在 Blackberry 应用程序中设置备用入口点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3921029/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com