# ReceivingSession

# ReceivingSession

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/com/google/ambient/crossdevice/sessions/ReceivingSession "View this page in Kotlin")\|Java

<br />

```
@RequiresApi(value = 26) interface ReceivingSession extends TransferrableSession
```

<br />

*** ** * ** ***

Describes a Session that is in the process of being transferred to another device. The receiver of the Session will use this class to initialize the application.

## Summary

|                                                                                                                                                                                                                                                                                                                                              ### Public methods                                                                                                                                                                                                                                                                                                                                               ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `abstract @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId)                                                                                                                                                                                                       | [onComplete](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/ReceivingSession#onComplete())`()` Called when the receiving device is initialized and ready to run the Session.                                                                                      |
| `abstract @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[ListenableFuture](https://developer.android.com/reference/com/google/common/util/concurrent/ListenableFuture)`<@`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId)`>` | [onCompleteFuture](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/ReceivingSession#onCompleteFuture())`()` Java-compatible version of[onComplete](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/ReceivingSession#onComplete()). |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ### Inherited methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| From class[com.google.ambient.crossdevice.sessions.TransferrableSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/TransferrableSession) |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `abstract void`                                                                                                                                                                                                                                                              | [cancelTransfer](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/TransferrableSession#cancelTransfer())`()` Cancels the transfer.                                                                                                                                                          | | `abstract @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[ListenableFuture](https://developer.android.com/reference/com/google/common/util/concurrent/ListenableFuture)`<`[Unit](https://developer.android.com/reference/kotlin/Unit)`>` | [cancelTransferFuture](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/TransferrableSession#cancelTransferFuture())`()` Java-compatible version of[cancelTransfer](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/TransferrableSession#cancelTransfer()). | | `abstract @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SessionRemoteConnection](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionRemoteConnection)                                              | [getStartupRemoteConnection](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/TransferrableSession#getStartupRemoteConnection())`()` Gets communication channel to send initialization messages back and forth between the originating and receiving device.                                | |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ### Inherited fields                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| From class[com.google.ambient.crossdevice.sessions.TransferrableSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/TransferrableSession) |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `abstract @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId) | [sessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/TransferrableSession#sessionId()) [SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId)this[TransferrableSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/TransferrableSession)belongs to. | |

## Public methods

### onComplete

```
abstract @NonNull SessionId onComplete()
```

Called when the receiving device is initialized and ready to run the Session. After this call, all methods will throw[SessionException](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionException)with[HANDLE_INVALIDATED](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionException.Companion#HANDLE_INVALIDATED()).  

|                                                                                                                                                         Returns                                                                                                                                                         ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
| `@`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId) | The[SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId)that was received. |

|                                                                                                                                                                                                  Throws                                                                                                                                                                                                   ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [com.google.ambient.crossdevice.sessions.SessionException](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionException)` com.google.ambient.crossdevice.sessions.SessionException` | if the transfer cannot be completed for any reason: - Session transfer is cancelled already (by either originating or receiving device) - Handle is invalidated - Internal error |

### onCompleteFuture

```
abstract @NonNull ListenableFuture<@NonNull SessionId> onCompleteFuture()
```

Java-compatible version of[onComplete](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/ReceivingSession#onComplete()).