Work With A Message - Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVICE APPLICATIONS INTEGRATION - DEVELOPMENT GUIDE Integration Manual

Blackberry device applications integration guide
Table of Contents

Advertisement

Work with a message

Task
Receive a message notification.
Add a listener to the message store.
Add a listener to the message store for
batch updates.
Add a listener to a folder.
Retrieve the total count of unread
messages in all folders in the store.
Steps
FolderListener
1. Implement the
public class MailTest implements FolderListener, StoreListener { ... }
ControlledAccessException
2. Create code to manage a
Store
1. Retrieve the
object.
StoreListener
2. Add a
instance to it.
3. Create a try-catch block to manage a
try {
Store store = Session.waitForDefaultSession().getStore();
} catch (NoSuchServiceException e) {
System.out.println(e.toString());
}
store.addStoreListener(this);
StoreListener.batchOperation()
>
Implement
void batchOperation(StoreEvent e) {
// Perform action when messages added or removed in batch operation.
}
Folder
1. Retrieve the
object for which you want to receive new message notifications.
Folder[] folders = store.list(Folder.INBOX);
Folder inbox = folders[0];
FolderListener
2. Add the
inbox.addFolderListener(this);
FolderListener.messagesAdded()
3. Implement
FolderListener.messagesRemoved()
void messagesAdded(FolderEvent e) {
// Perform processing on added messages.
}
void messagesRemoved(FolderEvent e) {
// Perform processing on removed messages.
}
net.rim.blackberry.api.mail.Store.getUnreadMessageCount()
>
Invoke
int numUnread = store.getUnreadMessageCount();
StoreListener
and
NoSuchServiceException
.
instance to the folder.
and
.
3: Work with a message
interfaces.
.
.
.
15

Advertisement

Table of Contents
loading

This manual is also suitable for:

Java development environment 4.6.0

Table of Contents