Listen for and handle multi-line events

For BlackBerry® devices that support multiple phone lines, you can configure your application to listen for and automatically handle multi-line phone events by using the MultiLineListener class. The MultiLineListener class is a helper class that implements the PhoneListener interface and provides a set of callback methods that you can use to receive notification of multi-line phone events.

  1. Import the required classes.
  2. Create a class that extends MultiLineListener.
  3. Register the class as a PhoneListener by invoking Phone.addPhoneListener().
  4. To handle line switching events, perform the following actions:
    1. Override the MultiLineListener callback methods to notify the application when a line switching event occurs. This is particularly important when using this feature on devices that operate on CDMA networks, as a delay might occur when the application switches between phone lines.
      public void setPreferredLineFailure(int lineId)
          _screen.popupMessage("switching failed.");
      public void setPreferredLineSuccess(int lineId)
          _screen.popupMessage("Switching succeeded to " + 
             Phone.getLineNumber(lineId) + " completed." );
    2. Invoke Phone.setPreferredLine(), passing in the line ID of the phone line to switch to. In the following code sample, the application selects the line that returns at index 0.
       Phone.setPreferredLine( Phone.getLineIds()[0]);

Was this information helpful? Send us your comments.