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.ListenerListener 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.StateDefines 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
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 withintimeoutseconds. Default value (defined
        by SIP protocol) is used iftimeoutis zero or negative. | 
changeCall
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 withintimeoutseconds. Default value (defined
        by SIP protocol) is used iftimeoutis zero or negative. | 
endCall
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
public String getCallId ()
Gets the call ID of the session.
| Returns | |
|---|---|
| String | the call ID | 
getLocalIp
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
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
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
public int getState ()
Gets the session state. The value returned must be one of the states in
 State.
| Returns | |
|---|---|
| int | the session state | 
isInCall
public boolean isInCall ()
Checks if the session is in a call.
| Returns | |
|---|---|
| boolean | true if the session is in a call | 
makeCall
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 withintimeoutseconds. Default value (defined
        by SIP protocol) is used iftimeoutis zero or negative. | 
See also:
register
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 | 
See also:
setListener
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
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.
See also:
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
