我想,当从应用程序的消息文件夹中打开一条消息,有一个听众。 为此,我利用ApplicationMenuItem的,但登记之后,该消息无法再打开。
ApplicationMessageFolderRegistry messagefolderRegistry = ApplicationMessageFolderRegistry.getInstance();
messaageMenuItemListener = new CVSMessaageMenuItemListener();
CVSApplicationMenuItem menuItem = new CVSApplicationMenuItem();
menuItem.registerMenuItemListener(messaageMenuItemListener);
messagefolderRegistry.registerMessageMenuItems(CVSApplicationMessage.TYPE_ALARMS, ApplicationMessage.Status.UNOPENED, new ApplicationMenuItem[]{menuItem});
messagefolderRegistry.registerMessageIcon(CVSApplicationMessage.TYPE_ALARMS, ApplicationMessage.Status.UNOPENED, alarmsIcon);
和菜单项:
public class CVSApplicationMenuItem extends ApplicationMenuItem {
private CVSVector listeners;
CVSApplicationMenuItem(){
super(20);
}
public Object run(Object context) {
if(!(context instanceof CVSApplicationMessage))
return context;
CVSApplicationMessage applicationMessage = (CVSApplicationMessage)context;
if(listeners == null)
return context;
for (int i = 0; i < listeners.size(); i++) {
((ICVSApplicationMessageMenuItemListener)listeners.itemAt(i)).messageReaded(applicationMessage);
}
return context;
}
public void registerMenuItemListener(ICVSApplicationMessageMenuItemListener l){
if(listeners == null)
listeners = new CVSVector();
if(l != null)
listeners.addItem(l);
}
public String toString() {
return null;
}
}
我可以看到在消息列表(从家里通知图标打开)的消息,但不能打开它。 如果我做它的工作原理如下,不过那时候我也当消息它打开没有回调:
//messagefolderRegistry.registerMessageMenuItems(CVSApplicationMessage.TYPE_ALARMS, ApplicationMessage.Status.UNOPENED, new ApplicationMenuItem[]{menuItem});