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