Ejemplo de código: responder a los cambios de un contacto en la lista de contactos
El siguiente ejemplo de código asume que la clase que insertó MyBBMContactListScreen tiene acceso al objeto BBMPlatformContext de esta aplicación y que lo ha pasado al constructor 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";
}
}
}
Tema siguiente: Enviar una invitación para una sesión a un contacto
¿Le ha resultado útil esta información? Envíenos sus comentarios.