2

I want to know when the user opens a message from the notification area (opened from the home screen - clicked on the app notification icon) thrown by my app.

ApplicationMessageFolderListener do not work for this and registering an applicationMenuItem cause the message to not open anymore (see Blackberry - use of ApplicationMenuItem when opening a message).

Does anybody know how to do this?

Community
  • 1
  • 1
Alexandru Circus
  • 5,478
  • 7
  • 52
  • 89
  • 1
    ApplicationMessageFolderListener is being implemented? and the the actionPerformed method added? – stack_ved Dec 24 '12 at 09:49
  • yes, it's implemented, but is called just once with MARK_OLD action and with empty array of messages. See "http://stackoverflow.com/questions/8536271/blackberry-open-application-on-mesage-notification-click" - "hen a user opens an ApplicationMessage object, ApplicationMessageFolderListener.actionPerformed() is not notified. It is notified if the user marks the message as opened without actually opening it. After some digging, this is by design" – Alexandru Circus Dec 27 '12 at 09:45

1 Answers1

0

The below code should be of some help:

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

Get existing messages from storage and register them in folders.

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

Register ourselves as a listener for callback notifications.

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

i just get the feeling while adding listener to the inbox, you may be missing out on the the options you are setting like

ApplicationMessageFolderListener.MESSAGE_DELETED | 
ApplicationMessageFolderListener.MESSAGE_MARKED_OPENED | 
ApplicationMessageFolderListener.MESSAGE_MARKED_UNOPENED

so, actionPerformed() is getting called only for the first time to mark it old or something.

biddulph.r
  • 5,226
  • 3
  • 32
  • 47
stack_ved
  • 721
  • 3
  • 11
  • thanks for your answer, but it won't work for me. When opening the message, the listener is not called. If I delete the message, then it is called. – Alexandru Circus Dec 28 '12 at 10:03
  • applicationMessageFolder.addListener(alarmsMessageFolderListener, ApplicationMessageFolderListener.MESSAGE_DELETED | ApplicationMessageFolderListener.MESSAGE_MARKED_OPENED | ApplicationMessageFolderListener.MESSAGE_MARKED_UNOPENED, daemonDescr); – Alexandru Circus Dec 28 '12 at 10:05