Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE Průvodce řešením problémů Strana 155

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 286
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 154
155
10: Using the messages application
Work with a message
Open a message
1. Retrieve the message store and the folder that contains the message.
Task Steps
Receive a message notification. 1. Implement the FolderListener and StoreListener interfaces.
public class MailTest implements FolderListener, StoreListener { ... }
2. Create code to manage a ControlledAccessException.
Add a listener to the message store. 1. Retrieve the Store object.
2. Add a StoreListener instance to it.
3. Create a try-catch block to manage a NoSuchServiceException.
try {
Store store = Session.waitForDefaultSession().getStore();
} catch (NoSuchServiceException e) {
System.out.println(e.toString());
}
store.addStoreListener(this);
Add a listener to the message store for
batch updates.
> Implement StoreListener.batchOperation().
void batchOperation(StoreEvent e) {
// Perform action when messages added or removed in batch operation.
}
Add a listener to a folder. 1. Retrieve the Folder object for which you want to receive new message notifications.
Folder[] folders = store.list(Folder.INBOX);
Folder inbox = folders[0];
2. Add the FolderListener instance to the folder.
inbox.addFolderListener(this);
3. Implement FolderListener.messagesAdded() and
FolderListener.messagesRemoved().
void messagesAdded(FolderEvent e) {
// Perform processing on added messages.
}
void messagesRemoved(FolderEvent e) {
// Perform processing on removed messages.
}
Get more of a message. By default, the first section of a message (typically about 2 KB) is sent to the BlackBerry® device.
1. To determine whether more data is available on the server, invoke hasMore() on a body part .
2. To determine if the BlackBerry device user made a request for more data, invoke
moreRequestSent() .
3. To request more of a message, invoke more(). The second parameter of more() is a Boolean
value that specifies whether to retrieve only the next section of the body part (false) or all
remaining sections of the body part (true).
if (( bp.hasMore() ) && (! bp.moreRequestSent()) {
Transport.more(bp, true);
}
Zobrazit stránku 154
1 2 ... 150 151 152 153 154 155 156 157 158 159 160 ... 285 286

Komentáře k této Příručce

Žádné komentáře