Android APIs
public final class

SipSession

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

Class Overview

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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void answerCall (String sessionDescription, int timeout)

Added in API level 9

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

Parameters
sessionDescription the session description to answer this call
timeout 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.

public void changeCall (String sessionDescription, int timeout)

Added in API level 9

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

Parameters
sessionDescription the new session description
timeout 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.

public void endCall ()

Added in API level 9

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 IN_CALL, INCOMING_CALL, OUTGOING_CALL or OUTGOING_CALL_RING_BACK.

public String getCallId ()

Added in API level 9

Gets the call ID of the session.

Returns
  • the call ID

public String getLocalIp ()

Added in API level 9

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

Returns
  • the IP address of the local host

public SipProfile getLocalProfile ()

Added in API level 9

Gets the SIP profile that this session is associated with.

Returns
  • the SIP profile that this session is associated with

public SipProfile getPeerProfile ()

Added in API level 9

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

Returns
  • the SIP profile that this session is connected to

public int getState ()

Added in API level 9

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

Returns
  • the session state

public boolean isInCall ()

Added in API level 9

Checks if the session is in a call.

Returns
  • true if the session is in a call

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

Added in API level 9

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 READY_TO_CALL.

Parameters
callee the SIP profile to make the call to
sessionDescription the session description of this call
timeout 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.

public void register (int duration)

Added in API level 9

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 READY_TO_CALL.

Parameters
duration duration in second before the registration expires

public void setListener (SipSession.Listener listener)

Added in API level 9

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 to listen to the session events of this object

public void unregister ()

Added in API level 9

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 READY_TO_CALL.