无法使用LocalNotificationCallBack显示使用Codenameone显示通知的表单
当用户不在应用程序中时,我使用LocalNotifications显示消息。现在的挑战是回调。我正在创建的表单在调用回调后不显示。下面是回调的my代码无法使用LocalNotificationCallBack显示使用Codenameone显示通知的表单,codenameone,Codenameone,当用户不在应用程序中时,我使用LocalNotifications显示消息。现在的挑战是回调。我正在创建的表单在调用回调后不显示。下面是回调的my代码 if (notificationId.startsWith("prospect")) { Display.getInstance().callSerially(new Runnable() { public void run() { // this occurs on
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;
可以在调用
start
方法之前调用回调,该方法可能会覆盖您的设置。将主类中的currentForm
变量设为静态,然后可以执行以下操作:
MyMainClass.currentForm = f;
该表单仅在我点击或单击表单后显示。这是我的代码f.add(cc);f、 后退命令(后退)//f、 show()//f、 重新油漆();MyMainClass.main=f;MyMainClass.main.revalidate();MyMainClass.main.repaint();MyMainClass.main.show();//main.removeAll();//main.setTitle(“前景警报”)//removeAllCommands(show()之后不需要重新绘制()这可能会导致一个问题。我的解决方案仍然适用,因为两种形式都显示了,并且您会遇到空中碰撞。我建议的解决方案会解决这个问题。是的,我意识到,然后继续解决这个确切的问题。解决方案是一个延迟,因为首先调用start方法,然后以1秒的延迟显示使用UITimer的形式。谢谢对于表单显示的方向,但仅在我点击或单击表单后显示。这是我的代码f.add(cc);f.setBackCommand(back);//f.show();//f.repaint();MyMainClass.main=f;MyMainClass.main.revalidate();MyMainClass.main.repaint();MyMainClass.main.show();//main.removeAll();//main.setTitle(“前景警报”);//main.removeAllCommands(在show()之后不需要重新绘制()这可能会导致一个问题。我的解决方案仍然适用,因为两种形式都显示了,并且您会遇到空中碰撞。我建议的解决方案会解决这个问题。是的,我意识到,然后继续解决这个确切的问题。解决方案是一个延迟,因为首先调用start方法,然后以1秒的延迟显示使用UITimer的形式。谢谢方向