Prévenir une application de terminal BlackBerry lorsqu'un e-mail est sur le point d'être envoyé
- Importez les classes et les interfaces requises.
import net.rim.blackberry.api.mail.NoSuchServiceException;
import net.rim.blackberry.api.mail.SendListener;
import net.rim.blackberry.api.mail.Session;
import net.rim.blackberry.api.mail.Store;
- Implémentez l'interface SendListener.
public class MailSendListener implements SendListener{...}
- Créez une instance de la classe déployant l'interface SendListener.
MailSendListener mailSL = new mailSendListener();
- Dans un bloc try, appelez Session.waitForDefaultSession().getStore() pour récupérer l'objet Store.
try
{
Store store = Session.waitForDefaultSession().getStore();
}
- Dans un bloc catch, gérez une exception NoSuchServiceException.
catch (NoSuchServiceException e)
{
System.out.println(e.toString());
}
- Appelez Store.addSendListener(MailSendListener) pour ajouter une instance de SendListener.
store.addSendListener(mailSL);
Ces informations vous ont-elles été utiles ? Envoyez-nous vos commentaires.