Respond to a contact's changes in your contact list
Before you begin: Make sure that you
have completed the task,
Register your
application with the BlackBerry Messenger platform, and that the class
that displays the screen passes in a reference to the application's associated
BBMPlatformContext object.
Code sample: Responding to a contact's changes in your contact list
The following code sample assumes that the class that pushed the MyBBMContactListScreen has access to the BBMPlatformContext object for this application and has passed it into the MyBBMContactListScreen constructor.
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";
}
}
}
Next topic: Send a session invitation to a contact