0

我正在开发应用程序,我必须从主函数注册两个侦听器。在两个中,一个用于注册推送通知,另一个用于当通知到来时,将在通知栏上显示图标,单击我必须启动应用程序。我在代码中做错了,但不知道在哪里请帮助我。

public static void main(String[] args)
{
    // Create a new instance of the application and make the currently
    // running thread the application's event dispatch thread.
    //System.out.println("====main function===="+args[0]);
    System.out.println("====args.length==="+args.length);

    if(args.length > 0 && args[0].equals("BB_push") )
    {

        System.out.println("====IN IF====");

        theApp = new MyApp();       
        theApp.enterEventDispatcher();


    }else if(args.length == 1 && args[0].equals("gui"))
    {
        System.out.println("====IN 1 GUI===");
        // Create a GUI instance for displaying a DemoMessageScreen.
        // This will occur when this application is invoked by the
        // View Demo Message menu item.
        MyApp messageScreenApp = new MyApp();
        messageScreenApp.enterEventDispatcher();

    }
    else{

        MessageListDemoDaemon daemon = new MessageListDemoDaemon();

        // Register application indicator
        EncodedImage indicatorIcon = EncodedImage.getEncodedImageResource("img/indicator.png");
        ApplicationIcon applicationIcon = new ApplicationIcon(indicatorIcon);
        ApplicationIndicatorRegistry.getInstance().register(applicationIcon, false, false);
        ApplicationMessageFolderRegistry reg = ApplicationMessageFolderRegistry.getInstance();
        if(reg.getApplicationFolder(INBOX_FOLDER_ID) == null)
        {
            daemon.init();
        }
try
{
        daemon.enterEventDispatcher();
}catch (Exception e) 
{
System.out.println("======catch after daemnon even===="+e);

}

        // push notificationlistener===============
        BackgroundApplication backApp=new BackgroundApplication();
        register.registerBpas();
        backApp.setupBackgroundApplication();

        backApp.enterEventDispatcher();
    }

}
4

1 回答 1

2

试试这个 -

public static void main(String[] args)
{

   if(args != null && args.length > 0 && args[0].equals("gui"))
     {

       //Main Screen 

    }
    else if(args != null && args.length > 0 && args[0].equals("Background1")) {

       //First background application


    }else{

       //Second background application 

    }

在您的BlackBerry_App_Descriptor.xml - 1.应用程序 - 标记 - 启动时自动运行并且不在主屏幕上显示应用程序图标。 2.备用入口点 - A)。gui- 取消选中 - 启动时自动运行,并且不在主屏幕上显示应用程序图标。 乙)。Background1 - 标记 - 启动时自动运行,并且不在主屏幕上显示应用程序图标。

于 2013-04-04T07:04:01.250 回答