Échantillon de code : Réponse à une modification d'un contact dans votre liste de contacts
L'échantillon de code suivant suppose que la classe qui a affiché MyBBMContactListScreen a accès à l'objet BBMPlatformContext pour cette application et l'a transmis au constructeur MyBBMContactListScreen.
import net.rim.blackberry.api.bbm.platform.*;
import net.rim.device.api.ui.component.*;
public class MyBBMContactListScreen implements PresenceListener
{
public MyClass(BBMPlatformContext platformContext)
{
platformContext.getContactListService().setPresenceListener(this);
}
public void presenceUpdated(BBMPlatformContact contact, int eventType)
{
final String str = "[" + getEventName(eventType) + "] was changed by " + contact.getDisplayName();
Dialog.inform(str);
}
private String getEventName(int eventType)
{
String eventName;
switch(eventType)
{
case PresenceListener.EVENT_TYPE_DISPLAY_PICTURE:
eventName = "Display picture";
break;
case PresenceListener.EVENT_TYPE_DISPLAY_NAME:
eventName = "Display name";
break;
case PresenceListener.EVENT_TYPE_PERSONAL_MESSAGE:
eventName = "Personal Message";
break;
case PresenceListener.EVENT_TYPE_STATUS:
eventName = "Status";
break;
default:
eventName = "Default";
}
}
}
Sujet suivant: Envoyer une invitation de session à un contact
Sujet précédent: Répondez aux modifications d'un contact dans votre liste de contacts
Ces informations vous ont-elles été utiles ? Envoyez-nous vos commentaires.