Listen for and handle phone events

You can configure your BlackBerry® device application to listen for and automatically handle various phone events by implementing the PhoneListener interface. The PhoneListener interface provides a set of callback methods that you can use to receive notification of phone events.

  1. Import the required classes and interfaces.
    import net.rim.blackberry.api.phone.*;
  2. Create a class that implements the PhoneListener interface.
  3. Register the class that implements PhoneListener by invoking addPhoneListener().
    Phone.addPhoneListener(this);
  4. Handle incoming phone events by using the PhoneListener callback methods. For example, to receive notification that a call is disconnected, implement the notification in callDisconnected(int); to receive notification that a new call has arrived, implement the notification in callIncoming(int); and to receive notification that a call is waiting, implement the notification in callWaiting(int). For a complete list of PhoneListener callback methods, see the API reference for the BlackBerry® Java® Development Environment
  5. To deregister the PhoneListener, invoke Phone.removePhoneListener().
     Phone.removePhoneListener(this);
Previous topic: BlackBerry DTMF tones

Was this information helpful? Send us your comments.