Blackberry - 在打开applicationMessage时监听

时间:2012-12-24 08:23:09

标签: blackberry blackberry-jde

我想知道用户何时从我的应用程序抛出的通知区域(从主屏幕打开 - 点击应用程序通知图标)打开消息。

ApplicationMessageFolderListener不适用于此并注册applicationMenuItem会导致邮件不再打开(请参阅Blackberry - use of ApplicationMenuItem when opening a message)。

有人知道怎么做吗?

1 个答案:

答案 0 :(得分:0)

以下代码应该有所帮助:

ApplicationMessageFolderRegistry registry =
    ApplicationMessageFolderRegistry.getInstance();
ApplicationMessageFolder inbox = 
    registry.getApplicationFolder(MessageListHelper.YOUR_CUSTOM_INBOX_FOLDER_ID);
ApplicationDescriptor daemonDescr = 
    ApplicationDescriptor.currentApplicationDescriptor();

从存储中获取现有消息并将其注册到文件夹中。

MessageStore messages = MessageListHelper.getMessageStore();
ApplicationMessageFolder inbox =
   registry.registerFolder(MessageListHelper.YOUR_CUSTOM_INBOX_FOLDER_ID, 
   "Inbox", messages.getInboxMessages());

将自己注册为回调通知的监听器。

inbox.addListener(this, ApplicationMessageFolderListener.MESSAGE_DELETED |
   ApplicationMessageFolderListener.MESSAGE_MARKED_OPENED |
   ApplicationMessageFolderListener.MESSAGE_MARKED_UNOPENED, daemonDescr);
messages.setFolders(inbox);
registry.setRootFolderName(MessageListHelper.ROOT_FOLDER_NAME);

我只是在将收听者添加到收件箱时感觉到,您可能会错过您设置的选项

ApplicationMessageFolderListener.MESSAGE_DELETED | 
ApplicationMessageFolderListener.MESSAGE_MARKED_OPENED | 
ApplicationMessageFolderListener.MESSAGE_MARKED_UNOPENED

所以,actionPerformed()仅在第一次被调用时才将其标记为旧版本。