1

当从应用程序消息文件夹打开消息时,我希望有一个侦听器。为此,我使用了 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});
4

1 回答 1

0

据我了解,您不再看到系统“消息预览”屏幕。我有同样的问题。似乎当您注册菜单项时,它会完全覆盖打开操作。我检查了Message List Demo,发现他们在 ApplicationMenuItem 的 run() 方法中打开了自定义预览消息屏幕。由于我没有找到用我的消息打开系统“消息预览”屏幕的任何方法,我也将实现自定义屏幕。

于 2013-01-05T14:52:48.093 回答