Added in API level 9
Deprecated in API level 31

SipSession


public final class SipSession
extends Object

java.lang.Object
   ↳ android.net.sip.SipSession


This class was deprecated in API level 31.
SipManager and associated classes are no longer supported and should not be used as the basis of future VOIP apps.

Represents a SIP session that is associated with a SIP dialog or a standalone transaction not within a dialog.

You can get a SipSession from SipManager with createSipSession() (when initiating calls) or getSessionFor() (when receiving calls).

Summary

Nested classes

class SipSession.Listener

Listener for events relating to a SIP session, such as when a session is being registered ("on registering") or a call is outgoing ("on calling"). 

class SipSession.State

Defines SIP session states, such as "registering", "outgoing call", and "in call". 

Public methods

void answerCall(String sessionDescription, int timeout)

Answers an incoming call with the specified session description.

void changeCall(String sessionDescription, int timeout)

Changes the session description during a call.

void endCall()

Ends an established call, terminates an outgoing call or rejects an incoming call.

String getCallId()

Gets the call ID of the session.

String getLocalIp()

Gets the IP address of the local host on which this SIP session runs.

SipProfile getLocalProfile()

Gets the SIP profile that this session is associated with.

SipProfile getPeerProfile()

Gets the SIP profile that this session is connected to.

int getState()

Gets the session state.

boolean isInCall()

Checks if the session is in a call.

void makeCall(SipProfile callee, String sessionDescription, int timeout)

Initiates a call to the specified profile.

void register(int duration)

Performs registration to the server specified by the associated local profile.

void setListener(SipSession.Listener listener)

Sets the listener to listen to the session events.

void unregister()

Performs unregistration to the server specified by the associated local profile.

Inherited methods

Public methods

answerCall

Added in API level 9
public void answerCall (String sessionDescription, 
                int timeout)

Answers an incoming call with the specified session description. The method is only valid to call when the session state is in State.INCOMING_CALL.

Parameters
sessionDescription String: the session description to answer this call

timeout int: the session will be timed out if the call is not established within timeout seconds. Default value (defined by SIP protocol) is used if timeout is zero or negative.

changeCall

Added in API level 9
public void changeCall (String sessionDescription, 
                int timeout)

Changes the session description during a call. The method is only valid to call when the session state is in State.IN_CALL.

Parameters
sessionDescription String: the new session description

timeout int: the session will be timed out if the call is not established within timeout seconds. Default value (defined by SIP protocol) is used if timeout is zero or negative.

endCall

Added in API level 9
public void endCall ()

Ends an established call, terminates an outgoing call or rejects an incoming call. The method is only valid to call when the session state is in State.IN_CALL, State.INCOMING_CALL, State.OUTGOING_CALL or State.OUTGOING_CALL_RING_BACK.

getCallId

Added in API level 9
public String getCallId ()

Gets the call ID of the session.

Returns
String the call ID

getLocalIp

Added in API level 9
public String getLocalIp ()

Gets the IP address of the local host on which this SIP session runs.

Returns
String the IP address of the local host

getLocalProfile

Added in API level 9
public SipProfile getLocalProfile ()

Gets the SIP profile that this session is associated with.

Returns
SipProfile the SIP profile that this session is associated with

getPeerProfile

Added in API level 9
public SipProfile getPeerProfile ()

Gets the SIP profile that this session is connected to. Only available when the session is associated with a SIP dialog.

Returns
SipProfile the SIP profile that this session is connected to

getState

Added in API level 9
public int getState ()

Gets the session state. The value returned must be one of the states in State.

Returns
int the session state

isInCall

Added in API level 9
public boolean isInCall ()

Checks if the session is in a call.

Returns
boolean true if the session is in a call

makeCall

Added in API level 9
public void makeCall (SipProfile callee, 
                String sessionDescription, 
                int timeout)

Initiates a call to the specified profile. The session listener is called back upon defined session events. The method is only valid to call when the session state is in State.READY_TO_CALL.

Parameters
callee SipProfile: the SIP profile to make the call to

sessionDescription String: the session description of this call

timeout int: the session will be timed out if the call is not established within timeout seconds. Default value (defined by SIP protocol) is used if timeout is zero or negative.

register

Added in API level 9
public void register (int duration)

Performs registration to the server specified by the associated local profile. The session listener is called back upon success or failure of registration. The method is only valid to call when the session state is in State.READY_TO_CALL.

Parameters
duration int: duration in second before the registration expires

setListener

Added in API level 9
public void setListener (SipSession.Listener listener)

Sets the listener to listen to the session events. A SipSession can only hold one listener at a time. Subsequent calls to this method override the previous listener.

Parameters
listener SipSession.Listener: to listen to the session events of this object

unregister

Added in API level 9
public void unregister ()

Performs unregistration to the server specified by the associated local profile. Unregistration is technically the same as registration with zero expiration duration. The session listener is called back upon success or failure of unregistration. The method is only valid to call when the session state is in State.READY_TO_CALL.