Blackberry - use of ApplicationMenuItem when opening a message

痴心易碎 提交于 2019-12-02 07:57:41

问题


I want to have a listener when a message is opened from the application messages folder. For this I make use of ApplicationMenuItem, but after registering it, the message could not be opened anymore.

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);

and the menuItem:

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;
    }

}

I can see the message in the messages list (opened from home notification icon), but cannot open it. If I do the following it works, but then I have no callback when the message it's opened:

//messagefolderRegistry.registerMessageMenuItems(CVSApplicationMessage.TYPE_ALARMS, ApplicationMessage.Status.UNOPENED, new ApplicationMenuItem[]{menuItem});

回答1:


As I understand you don't see system "Message preview" screen any more. I have same problem. Seems when you register menu item it completely overrides open action. I checked Message List Demo and found that they open custom preview message screen inside ApplicationMenuItem's run() method. As I didn't found any way to open system "Message preview" screen with my message I'm going to implement custom screen also.



来源:https://stackoverflow.com/questions/13995593/blackberry-use-of-applicationmenuitem-when-opening-a-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!