BlackBerry ApplicationMessageFolder
From BlackBerry JDE API 4.6.0, BlackBerry applications can create custom messages and folders that are visible in the message list. An application can create an ApplicationMessageFolder that contains messages that the application creates. When an application adds an ApplicationMessage to a folder, the folder appears in the message list. A BlackBerry device user can open and view the custom message in a screen of the application that contains contextual information for the message.
Key Steps of Using Application Folder:
1. Register Folder
Class: ApplicationMessageFolderRegistry
In this class, call the method:
registerFolder(long folderId, String folderName, ReadableList collection)
to register a folder. The tricky part is the ReadableList collection. Since ReadableList is an interface which is implemented by UnsortedReadableList class, so here, it is safe to use UnsortedReadableList to store the ApplicationMessages.
Also a note here is, if you store the ApplicationMessages in a Vector, here you need to call:
UnsortedReadableList.loadFrom(Vector)
2. Implement Interface ApplicationMessage
long timestamp
String contact
String subject
int type (optional)
int status (optional)
2. Add/Remove ApplicationMessage to/from ApplicationFolder
In the class of ApplicationMessageFolder, there are two useful methods:
fireElementAdded(ApplicationMessage msg)
fireElementRemoved(ApplicationMessage msg)
3. Customize MenuItems for ApplicationMessage
The class of ApplicationMenuItem ensures us to create our own menu items. What we need to do is to inherit the constructor from super(int), in which the 'int' indicates the position of the item in the menu.
Interestingly, the place to register the menu items is not the ApplicationMessageFolder or the ApplicationMessage, but ApplicationMessageFolderRegistry. The method is:
registerMessageMenuItems(int type, int status, ApplicationMenuItem [] menuItems)
Here the type and status are referred to the specific type ApplicationMessage, For example, incoming message type can have View and Reply actions while outgoing message can have View action only.
4. Run(Object o) method in ApplicationMenuItem
If you register the ApplicationMenuItem from Step 3, then the Object o in method Run(Object o) is the instance of the selected (focused) ApplicationMessage, which you can get the information from.
Good Reference:
http://rim.lithium.com/t5/Product-Management-The/
Discussion-Application-Messages-API/m-p/75783
ApplicationMenuItem:
http://www.blackberry.com/developers/docs/4.6.0api/net/rim/
blackberry/api/menuitem/ApplicationMenuItem.html
ApplicationMessageFolder:
http://www.blackberry.com/developers/docs/4.6.0api/net/rim/
blackberry/api/messagelist/ApplicationMessageFolder.html
ApplicationMessageFolderRegistry:
http://www.blackberry.com/developers/docs/4.6.0api/net/rim/
blackberry/api/messagelist/ApplicationMessageFolderRegistry.html
No comments:
Post a Comment