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.
-
Import the required classes.
import net.rim.blackberry.api.phone.Phone;
import net.rim.blackberry.api.phone.MultiLineListener;
-
Create a class that extends
MultiLineListener.
-
Register the class as a
PhoneListener by invoking
Phone.addPhoneListener().
Phone.addPhoneListener(this);
-
To handle line switching events, perform the following actions:
-
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." );
}
-
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.