Define a context change listener

The following example assumes that you are creating a private inner class as part of an application that requires a context change listener.
  1. Import the required classes and interfaces.
    import net.rim.blackberry.api.bbm.platform.*;
    import net.rim.device.api.ui.component.*;
  2. Create the framework for the context change service listener, defining the accessChanged() method. The accessErrorCode parameter is one of the fields from the BBMPlatformContext class (for example, ACCESS_BLOCKED_BY_IT_POLICY). The following code sample displays dialog boxes that informs the user what change has occurred.
    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*/ 
    
        }
    }

Was this information helpful? Send us your comments.