# SipSession

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Nested Classes](https://developer.android.com/reference/android/net/sip/SipSession#nestedclasses)\|[Methods](https://developer.android.com/reference/android/net/sip/SipSession#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/net/sip/SipSession#inhmethods)  

# SipSession

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/net/sip/SipSession "View this page in Kotlin")\|Java

`
public

final

class
SipSession
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|----------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.sip.SipSession |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 31.**   
[SipManager](https://developer.android.com/reference/android/net/sip/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](https://developer.android.com/reference/android/net/sip/SipSession)from[SipManager](https://developer.android.com/reference/android/net/sip/SipManager)with[createSipSession()](https://developer.android.com/reference/android/net/sip/SipManager#createSipSession(android.net.sip.SipProfile,%20android.net.sip.SipSession.Listener))(when initiating calls) or[getSessionFor()](https://developer.android.com/reference/android/net/sip/SipManager#getSessionFor(android.content.Intent))(when receiving calls).

<br />

## Summary

|                                                                                                                       ### Nested classes                                                                                                                        ||
|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class` | [SipSession.Listener](https://developer.android.com/reference/android/net/sip/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](https://developer.android.com/reference/android/net/sip/SipSession.State) Defines SIP session states, such as "registering", "outgoing call", and "in call".                                                                       |

|                                                                                                                                                                                                                                  ### Public methods                                                                                                                                                                                                                                   ||
|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                             | ` `[answerCall](https://developer.android.com/reference/android/net/sip/SipSession#answerCall(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` sessionDescription, int timeout) ` Answers an incoming call with the specified session description.                                                                                                |
| ` void`                                                                             | ` `[changeCall](https://developer.android.com/reference/android/net/sip/SipSession#changeCall(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` sessionDescription, int timeout) ` Changes the session description during a call.                                                                                                                  |
| ` void`                                                                             | ` `[endCall](https://developer.android.com/reference/android/net/sip/SipSession#endCall())`() ` Ends an established call, terminates an outgoing call or rejects an incoming call.                                                                                                                                                                                                               |
| ` `[String](https://developer.android.com/reference/java/lang/String)               | ` `[getCallId](https://developer.android.com/reference/android/net/sip/SipSession#getCallId())`() ` Gets the call ID of the session.                                                                                                                                                                                                                                                             |
| ` `[String](https://developer.android.com/reference/java/lang/String)               | ` `[getLocalIp](https://developer.android.com/reference/android/net/sip/SipSession#getLocalIp())`() ` Gets the IP address of the local host on which this SIP session runs.                                                                                                                                                                                                                      |
| ` `[SipProfile](https://developer.android.com/reference/android/net/sip/SipProfile) | ` `[getLocalProfile](https://developer.android.com/reference/android/net/sip/SipSession#getLocalProfile())`() ` Gets the SIP profile that this session is associated with.                                                                                                                                                                                                                       |
| ` `[SipProfile](https://developer.android.com/reference/android/net/sip/SipProfile) | ` `[getPeerProfile](https://developer.android.com/reference/android/net/sip/SipSession#getPeerProfile())`() ` Gets the SIP profile that this session is connected to.                                                                                                                                                                                                                            |
| ` int`                                                                              | ` `[getState](https://developer.android.com/reference/android/net/sip/SipSession#getState())`() ` Gets the session state.                                                                                                                                                                                                                                                                        |
| ` boolean`                                                                          | ` `[isInCall](https://developer.android.com/reference/android/net/sip/SipSession#isInCall())`() ` Checks if the session is in a call.                                                                                                                                                                                                                                                            |
| ` void`                                                                             | ` `[makeCall](https://developer.android.com/reference/android/net/sip/SipSession#makeCall(android.net.sip.SipProfile,%20java.lang.String,%20int))`(`[SipProfile](https://developer.android.com/reference/android/net/sip/SipProfile)` callee, `[String](https://developer.android.com/reference/java/lang/String)` sessionDescription, int timeout) ` Initiates a call to the specified profile. |
| ` void`                                                                             | ` `[register](https://developer.android.com/reference/android/net/sip/SipSession#register(int))`(int duration) ` Performs registration to the server specified by the associated local profile.                                                                                                                                                                                                  |
| ` void`                                                                             | ` `[setListener](https://developer.android.com/reference/android/net/sip/SipSession#setListener(android.net.sip.SipSession.Listener))`(`[SipSession.Listener](https://developer.android.com/reference/android/net/sip/SipSession.Listener)` listener) ` Sets the listener to listen to the session events.                                                                                       |
| ` void`                                                                             | ` `[unregister](https://developer.android.com/reference/android/net/sip/SipSession#unregister())`() ` Performs unregistration to the server specified by the associated local profile.                                                                                                                                                                                                           |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public methods

### answerCall

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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](https://developer.android.com/reference/android/net/sip/SipSession.State#INCOMING_CALL).

<br />

|                                                                                                Parameters                                                                                                ||
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `sessionDescription` | `String`: the session description to answer this call <br />                                                                                                                       |
| `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. <br /> |

### changeCall

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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](https://developer.android.com/reference/android/net/sip/SipSession.State#IN_CALL).

<br />

|                                                                                                Parameters                                                                                                ||
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `sessionDescription` | `String`: the new session description <br />                                                                                                                                       |
| `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. <br /> |

### endCall

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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](https://developer.android.com/reference/android/net/sip/SipSession.State#IN_CALL),[State.INCOMING_CALL](https://developer.android.com/reference/android/net/sip/SipSession.State#INCOMING_CALL),[State.OUTGOING_CALL](https://developer.android.com/reference/android/net/sip/SipSession.State#OUTGOING_CALL)or[State.OUTGOING_CALL_RING_BACK](https://developer.android.com/reference/android/net/sip/SipSession.State#OUTGOING_CALL_RING_BACK).

<br />

### getCallId

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String getCallId ()
```

Gets the call ID of the session.

<br />

|                                        Returns                                         ||
|--------------------------------------------------------------------|--------------------|
| [String](https://developer.android.com/reference/java/lang/String) | the call ID <br /> |

### getLocalIp

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String getLocalIp ()
```

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

<br />

|                                                   Returns                                                   ||
|--------------------------------------------------------------------|-----------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | the IP address of the local host <br /> |

### getLocalProfile

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public SipProfile getLocalProfile ()
```

Gets the SIP profile that this session is associated with.

<br />

|                                                                    Returns                                                                    ||
|----------------------------------------------------------------------------------|-------------------------------------------------------------|
| [SipProfile](https://developer.android.com/reference/android/net/sip/SipProfile) | the SIP profile that this session is associated with <br /> |

### getPeerProfile

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public SipProfile getPeerProfile ()
```

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

<br />

|                                                                  Returns                                                                   ||
|----------------------------------------------------------------------------------|----------------------------------------------------------|
| [SipProfile](https://developer.android.com/reference/android/net/sip/SipProfile) | the SIP profile that this session is connected to <br /> |

### getState

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getState ()
```

Gets the session state. The value returned must be one of the states in[State](https://developer.android.com/reference/android/net/sip/SipSession.State).

<br />

|             Returns             ||
|-------|--------------------------|
| `int` | the session state <br /> |

### isInCall

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean isInCall ()
```

Checks if the session is in a call.

<br />

|                      Returns                       ||
|-----------|-----------------------------------------|
| `boolean` | true if the session is in a call <br /> |

### makeCall

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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](https://developer.android.com/reference/android/net/sip/SipSession.State#READY_TO_CALL).

<br />

|                                                                                                Parameters                                                                                                ||
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `callee`             | `SipProfile`: the SIP profile to make the call to <br />                                                                                                                           |
| `sessionDescription` | `String`: the session description of this call <br />                                                                                                                              |
| `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. <br /> |

**See also:**

- [SipSession.Listener](https://developer.android.com/reference/android/net/sip/SipSession.Listener)  

### register

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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](https://developer.android.com/reference/android/net/sip/SipSession.State#READY_TO_CALL).

<br />

|                                  Parameters                                  ||
|------------|------------------------------------------------------------------|
| `duration` | `int`: duration in second before the registration expires <br /> |

**See also:**

- [SipSession.Listener](https://developer.android.com/reference/android/net/sip/SipSession.Listener)  

### setListener

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

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

<br />

|                                        Parameters                                        ||
|------------|------------------------------------------------------------------------------|
| `listener` | `SipSession.Listener`: to listen to the session events of this object <br /> |

### unregister

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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](https://developer.android.com/reference/android/net/sip/SipSession.State#READY_TO_CALL).

<br />

**See also:**

- [SipSession.Listener](https://developer.android.com/reference/android/net/sip/SipSession.Listener)