컨텍스트 변경 수신기 정의
다음 예에서는 컨텍스트 변경 수신기가 필요한 프로그램의 일부로 비공개 내부 클래스를 생성한다고 가정합니다.
- 필요한 클래스와 인터페이스를 가져옵니다.
import net.rim.blackberry.api.bbm.platform.*;
import net.rim.device.api.ui.component.*;
- 컨텍스트 변경 서비스 수신기의 프레임워크를 생성하여 accessChanged() 메서드를 정의합니다. accessErrorCode 매개 변수는 BBMPlatformContext 클래스(예: ACCESS_BLOCKED_BY_IT_POLICY)의 필드 중 하나입니다. 다음 코드 샘플은 사용자에게 변경 사항을 알려주는 대화 상자를 표시합니다.
class MyBBMPlatformContextListener extends BBMPlatformContextListener
{
public void accessChanged(boolean isAccessAllowed, int accessErrorCode)
{
if(isAccessAllowed)
{
Dialog.inform("Access to the platform context is now allowed.");
}
else
{
Dialog.inform("Access to the platform context is now disallowed because
of error:" + accessErrorCode);
}
}
public void appInvoked(int reason, Object param)
{
/*code for handling different contexts for invocation:
<reason> is a constant in BBMPlatformApplication prepended
with INVOKE, which tells you why this app was invoked and by
whom
<param> is an object representing a custom paramater with
more information about the invocation context*/
}
}
이 정보가 도움이 되었습니까? 의견을 보내 주십시오.