대화 상대 목록의 대화 상대 변경에 응답
시작하기 전에: BlackBerry Messenger 플랫폼에 프로그램 등록 작업을 완료하고 화면을 표시하는 클래스가 프로그램과 연결된 BBMPlatformContext 개체에 대한 참조를 전달하도록 합니다.
코드 샘플: 대화 상대 목록의 대화 상대 변경에 응답
다음 코드 샘플에서는 MyBBMContactListScreen을 푸시한 클래스가 이 프로그램의 BBMPlatformContext 개체에 액세스하여 이를 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";
}
}
}
다음 주제: 대화 상대에게 세션 초대 보내기
이전 주제: 코드 샘플: 프로그램을 설치한 대화 상대 목록 표시