Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Test an accessible BlackBerry device application

You can create a test screen reader and use it to test and debug your accessible app in BlackBerry Java Development Environment 4.6.1 or later or BlackBerry Java Plug-in for Eclipse with BlackBerry Component Package 4.6.1 or later.

Before you make your accessible app available to BlackBerry device users, you should test it on a production screen reader or an assistive technology app that is installed on a BlackBerry device to verify that your application works the way you want it to.

Import the required interface.

import net.rim.device.api.ui.accessibility.AccessibleEventListener;

Create a screen reader class that implements the AccessibleEventListener interface.

public class ScreenReader implements AccessibleEventListener 
{   
}

Implement accessibleEventOccurred() to handle the accessible events.

public synchronized void accessibleEventOccurred(
  int event, 
  Object oldValue, 
  Object newValue, 
  AccessibleContext context)
{
  switch(context.getAccessibleRole()) 
  {
    case AccessibleRole.APP_ICON: 
      ScreenReaderHandler.handleAppIcon(event, oldState, newState, context);
      break;
                
    case AccessibleRole.ICON: 
      ScreenReaderHandler.handleIcon(event, oldState, newState, context);
      break;

    ...
  } 
}

In the event-handling methods, include println() statements to specify the information that you want to generate about the accessible events.

static void handleIcon(int event, int oldValue, int newValue, AccessibleContext context)
{
  if(event == AccessibleContext.ACCESSIBLE_STATE_CHANGED) 
  {          
    if(Util.hasTransitionedToState( oldValue, newValue, AccessibleState.FOCUSED)) 
    {
      String appName = context.getAccessibleName();                
      System.out.println("---------------- SOUND: " + appName + " icon focused");
    }                
  }
}

In your accessible application, register the screen reader class as an accessible event listener.

_screenReader = new ScreenReader();
AccessibilityManager.setAccessibleEventListener(_screenReader);     

Build the accessible application and the screen reader.

Perform one of the following actions to display the console window:

  • In the BlackBerry Java Plug-in for Eclipse, on the Window menu, select Show View > Console.
  • In the BlackBerry JDE, on the View menu, click Output, and click the Debug tab.

Perform one of the following actions to start a debugging session:

  • In the BlackBerry Java Plug-in for Eclipse, right-click the CustomComponentsDemo project in the Project Explorer, then on the Debug As menu, select BlackBerry Simulator.
  • In the BlackBerry JDE, on the Debug menu, click Go.

In the BlackBerry Smartphone Simulator window, test your accessible application.

The console window displays the standard output that comes from the screen reader, which is listening for events on the UI components and processing the events.

---------------- SOUND:  Media  icon focused