繁体   English   中英

无法使用LocalNotificationCallBack显示使用Codenameone显示通知的表单

[英]failing to use LocalNotificationCallBack to display a form that displays a notification using Codenameone

当用户不在应用程序内时,我正在使用LocalNotifications显示消息。 现在的挑战是回调。 调用回调后,我正在创建的表单没有显示。 这是我的回调代码

  if (notificationId.startsWith("prospect")) {

        Display.getInstance().callSerially(new Runnable() {
            public void run() {
                // this occurs on the EDT so I can make changes to UI components
                String id = StringUtil.tokenize(notificationId, "-").get(1);

                Container cc = new Container(new BoxLayout(BoxLayout.Y_AXIS));
                String info = "We have hit the\n" + "end of the line";

                /*SpanLabel sp = new SpanLabel("Type: " + c.getTaskType()
                            + "\nNotes: " + notNullOrEmpty(c.getNotes()) + "\nWhen: "
                            + new Date(Long.parseLong(c.getTimestamp()))
                            + "\n Venue: " + c.getVenue(), "DialogBody");*/
                SpanLabel sp = new SpanLabel(info);
                sp.setRTL(false);

                sp.setTextBlockAlign(Component.LEFT);

                cc.add(sp);
                Form f = new Form("Prospect Alert", new BoxLayout(BoxLayout.Y_AXIS));

                final Command back = new Command(null) {
                    public void actionPerformed(ActionEvent evt) {

                        main.show();
                    }
                };

                f.add(cc);

                f.setBackCommand(back);
                f.show();
                f.repaint();
                //main.removeAll();
                //main.setTitle("Prospect Alert");
                // main.removeAllCommands();
                //main.add(sp);
                //main.revalidate();
                //mainStage.removeAll();
                // BorderLayout bl = new BorderLayout();
                // mainStage.setLayout(bl);
                //mainStage.addComponent(BorderLayout.CENTER, sp);

            }
        });

    }

可以在调用start方法之前调用该回调,并且该方法可能会覆盖您的设置。 将主类中的currentForm变量设为静态,然后可以执行以下操作:

MyMainClass.currentForm = f;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM