사용자 프로필
UserProfile 클래스를 사용해 현재 사용자의 BlackBerry® Messenger 프로필에 액세스하고 사용자의 표시 이름, 표시 사진, 상태 및 개인 메시지를 검색 또는 변경할 수 있습니다.
BBMPlatformContext.getUserProfile() 메서드를 호출하여 현재 사용자의 프로필에 대한 참조를 검색할 수 있습니다.
UserProfile 클래스는 또한 현재 사용자의 UserProfileBox 및 UserProfileLocation 인스턴스에 대한 검색 메서드를 제공합니다.
사용자 프로필 검색
시작하기 전에: BlackBerry Messenger 플랫폼에 프로그램 등록 작업을 완료하고 MyUserProfileScreen 화면을 표시하는 클래스가 프로그램과 연결된 BBMPlatformContext 개체에 대한 참조를 전달하도록 합니다.
코드 샘플: 사용자 프로필 검색
다음 코드 샘플에서는 MyUserProfileScreen을 표시한 클래스가 프로그램과 연결된 BBMPlatformContext 개체에 대한 참조를 MyUserProfileScreen 생성자에 전달했다고 가정합니다.
import net.rim.blackberry.api.bbm.platform.*;
import net.rim.blackberry.api.bbm.platform.profile.*;
import net.rim.device.api.ui.container.*;
import java.util.*;
public class MyUserProfileScreen extends MainScreen
{
public MyUserProfileScreen(BBMPlatformContext platformContext)
{
UserProfile userProfile = platformContext.getUserProfile();
String displayName = userProfile.getDisplayName();
Bitmap displayPicture = userProfile.getDisplayPicture();
String personalMsg = userProfile.getPersonalMessage();
int status = userProfile.getStatus();
String statusMsg = userProfile.getStatusMessage();
}
}
사용자 프로필 업데이트
시작하기 전에: BlackBerry Messenger 플랫폼에 프로그램을 등록하고 화면을 표시하는 클래스가 이 프로그램과 연결된 BBMPlatformContext 개체에 대한 참조를 전달하도록 합니다.
코드 샘플: 사용자 프로필 업데이트
다음 코드 샘플에서는 MyUserProfileScreen을 표시한 클래스가 프로그램과 연결된 BBMPlatformContext 개체에 대한 참조를 MyUserProfileScreen 생성자에 전달했다고 가정합니다.
import net.rim.blackberry.api.bbm.platform.*;
import net.rim.blackberry.api.bbm.platform.profile.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.component.*;
import java.util.*;
public class MyUserProfileScreen extends MainScreen
{
public MyUserProfileScreen(BBMPlatformContext platformContext)
{
UserProfile userProfile = platformContext.getUserProfile();
boolean allowed = userProfile.setStatus(Presence.STATUS_BUSY, "I am busy.");
if(! allowed)
{
int result = Dialog.ask(Dialog.D_YES_NO, "Would you like CoolApp to
stop updating your profile status?");
if(result == Dialog.YES)
{
// Optional code to prevent the application from asking to update
// the user's status
}
}
}
}
다음 주제: 사용자 프로필 상자
이전 주제: 사용자 프로필 및 프로필 상자 사용