# Sessions

# Sessions

*** ** * ** ***

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

<br />

```
@RequiresApi(value = 26) interface Sessions
```

<br />

*** ** * ** ***

Entry-point for creating and interacting with Sessions. Create a client by calling[Sessions.create](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions.Companion#create(android.content.Context)).

## Summary

|                                                      ### Nested types                                                       ||
|--------------------------------------------------------------------------------------------------------------------------|---|
| [Sessions.Companion](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions.Companion) |   |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `abstract @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId)                                                                                                                                                                                                                         | [createSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#createSession(com.google.ambient.crossdevice.sessions.ApplicationSessionTag))`(`[ApplicationSessionTag](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/ApplicationSessionTag)` applicationSessionTag)` Creates a Session which can be be transferred to or shared with another device.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `abstract @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[ReceivingSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/ReceivingSession)                                                                                                                                                                                                           | [getReceivingSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#getReceivingSession(android.content.Intent,com.google.ambient.crossdevice.sessions.ReceivingSessionStateCallback))`(` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[Intent](https://developer.android.com/reference/android/content/Intent)` intent,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[ReceivingSessionStateCallback](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/ReceivingSessionStateCallback)` callback` `)` Receives a[ReceivingSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/ReceivingSession)to transfer a Session to this device.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `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)` `[ReceivingSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/ReceivingSession)`>`     | [getReceivingSessionFuture](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#getReceivingSessionFuture(android.content.Intent,com.google.ambient.crossdevice.sessions.ReceivingSessionStateCallback))`(` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[Intent](https://developer.android.com/reference/android/content/Intent)` intent,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[ReceivingSessionStateCallback](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/ReceivingSessionStateCallback)` callback` `)` Java-compatible version of[getReceivingSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#getReceivingSession(android.content.Intent,com.google.ambient.crossdevice.sessions.ReceivingSessionStateCallback)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `abstract @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SecondarySession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SecondarySession)                                                                                                                                                                                                           | [getSecondarySession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#getSecondarySession(android.content.Intent,com.google.ambient.crossdevice.sessions.SecondarySessionStateCallback))`(` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[Intent](https://developer.android.com/reference/android/content/Intent)` intent,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SecondarySessionStateCallback](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SecondarySessionStateCallback)` callback` `)` Receives a[SecondarySession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SecondarySession)to join a Session from this device.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `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)` `[SecondarySession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SecondarySession)`>`     | [getSecondarySessionFuture](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#getSecondarySessionFuture(android.content.Intent,com.google.ambient.crossdevice.sessions.SecondarySessionStateCallback))`(` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[Intent](https://developer.android.com/reference/android/content/Intent)` intent,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SecondarySessionStateCallback](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SecondarySessionStateCallback)` callback` `)` Java-compatible version of[getSecondarySession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#getSecondarySession(android.content.Intent,com.google.ambient.crossdevice.sessions.SecondarySessionStateCallback)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `abstract void`                                                                                                                                                                                                                                                                                                                                                                                                             | [registerActivityResultCaller](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#registerActivityResultCaller(androidx.activity.result.ActivityResultCaller))`(` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[ActivityResultCaller](https://developer.android.com/reference/androidx/activity/result/ActivityResultCaller)` activityResultCaller` `)` Registers an[ActivityResultCaller](https://developer.android.com/reference/androidx/activity/result/ActivityResultCaller)to enable Sessions to show available devices via Discovery's device launcher.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `abstract void`                                                                                                                                                                                                                                                                                                                                                                                                             | [removeSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#removeSession(com.google.ambient.crossdevice.sessions.SessionId))`(@`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId)` sessionId)` Removes a Session so that it can no longer be discovered by other devices requesting transfer or share.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `abstract @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[ListenableFuture](https://developer.android.com/reference/com/google/common/util/concurrent/ListenableFuture)`<`[Void](https://developer.android.com/reference/java/lang/Void)`>`                                                                                                                                             | [removeSessionFuture](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#removeSessionFuture(com.google.ambient.crossdevice.sessions.SessionId))`(@`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId)` sessionId)` Java-compatible version of[removeSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#removeSession(com.google.ambient.crossdevice.sessions.SessionId)).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `abstract @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[PrimarySession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/PrimarySession)                                                                                                                                                                                                               | [shareSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#shareSession(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.wakeup.StartComponentRequest,kotlin.collections.List,com.google.ambient.crossdevice.sessions.PrimarySessionStateCallback))`(` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId)` sessionId,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[StartComponentRequest](https://developer.android.com/reference/com/google/ambient/crossdevice/wakeup/StartComponentRequest)` startComponentRequest,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[List](https://developer.android.com/reference/java/util/List)`<@`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[DeviceFilter](https://developer.android.com/reference/com/google/ambient/crossdevice/discovery/DeviceFilter)`> deviceFilters,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[PrimarySessionStateCallback](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback)` callback` `)` Invites another device to join a Session currently running on the device this function is called on.                                                                                                                                                                                                                                                                                                |
| `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)` `[PrimarySession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/PrimarySession)`>`         | [shareSessionFuture](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#shareSessionFuture(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.wakeup.StartComponentRequest,kotlin.collections.List,com.google.ambient.crossdevice.sessions.PrimarySessionStateCallback))`(` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId)` sessionId,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[StartComponentRequest](https://developer.android.com/reference/com/google/ambient/crossdevice/wakeup/StartComponentRequest)` startComponentRequest,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[List](https://developer.android.com/reference/java/util/List)`<@`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[DeviceFilter](https://developer.android.com/reference/com/google/ambient/crossdevice/discovery/DeviceFilter)`> deviceFilters,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[PrimarySessionStateCallback](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback)` callback` `)` Java-compatible version of[shareSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#shareSession(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.wakeup.StartComponentRequest,kotlin.collections.List,com.google.ambient.crossdevice.sessions.PrimarySessionStateCallback)).                             |
| `abstract @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[OriginatingSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/OriginatingSession)                                                                                                                                                                                                       | [transferSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#transferSession(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.wakeup.StartComponentRequest,kotlin.collections.List,com.google.ambient.crossdevice.sessions.OriginatingSessionStateCallback))`(` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId)` sessionId,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[StartComponentRequest](https://developer.android.com/reference/com/google/ambient/crossdevice/wakeup/StartComponentRequest)` startComponentRequest,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[List](https://developer.android.com/reference/java/util/List)`<@`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[DeviceFilter](https://developer.android.com/reference/com/google/ambient/crossdevice/discovery/DeviceFilter)`> deviceFilters,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[OriginatingSessionStateCallback](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/OriginatingSessionStateCallback)` callback` `)` Transfers a Session from the device this function is called on to another.                                                                                                                                                                                                                                                                                                        |
| `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)` `[OriginatingSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/OriginatingSession)`>` | [transferSessionFuture](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#transferSessionFuture(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.wakeup.StartComponentRequest,kotlin.collections.List,com.google.ambient.crossdevice.sessions.OriginatingSessionStateCallback))`(` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId)` sessionId,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[StartComponentRequest](https://developer.android.com/reference/com/google/ambient/crossdevice/wakeup/StartComponentRequest)` startComponentRequest,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[List](https://developer.android.com/reference/java/util/List)`<@`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[DeviceFilter](https://developer.android.com/reference/com/google/ambient/crossdevice/discovery/DeviceFilter)`> deviceFilters,` ` @`[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull)` `[OriginatingSessionStateCallback](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/OriginatingSessionStateCallback)` callback` `)` Java-compatible version of[transferSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#transferSession(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.wakeup.StartComponentRequest,kotlin.collections.List,com.google.ambient.crossdevice.sessions.OriginatingSessionStateCallback)). |

## Public methods

### createSession

```
abstract @NonNull SessionId createSession(ApplicationSessionTag applicationSessionTag)
```

Creates a Session which can be be transferred to or shared with another device. Returns the[SessionId](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionId)associated with that Session.  

|                                                                                                                                Parameters                                                                                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| [ApplicationSessionTag](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/ApplicationSessionTag)` applicationSessionTag` | A client-defined concept that optionally describes the high level type of experience for a Session within an app. |

### getReceivingSession

```
abstract @NonNull ReceivingSession getReceivingSession(
    @NonNull Intent intent,
    @NonNull ReceivingSessionStateCallback callback
)
```

Receives a[ReceivingSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/ReceivingSession)to transfer a Session to this device. Should be called from receiving device after app is launched by D2DI with an intent specified by the originating device.

App should pass the[intent](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#getReceivingSession(android.content.Intent,com.google.ambient.crossdevice.sessions.ReceivingSessionStateCallback))it was launched with as a parameter.  

|                                                                                                                              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 unable to return a`ReceivingSession`. |

### getReceivingSessionFuture

```
abstract @NonNull ListenableFuture<@NonNull ReceivingSession> getReceivingSessionFuture(
    @NonNull Intent intent,
    @NonNull ReceivingSessionStateCallback callback
)
```

Java-compatible version of[getReceivingSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#getReceivingSession(android.content.Intent,com.google.ambient.crossdevice.sessions.ReceivingSessionStateCallback)).  

### getSecondarySession

```
abstract @NonNull SecondarySession getSecondarySession(
    @NonNull Intent intent,
    @NonNull SecondarySessionStateCallback callback
)
```

Receives a[SecondarySession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SecondarySession)to join a Session from this device. Should be called from receiving device after app is launched by D2DI with an intent specified by the originating device.

App should pass the[intent](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#getSecondarySession(android.content.Intent,com.google.ambient.crossdevice.sessions.SecondarySessionStateCallback))it was launched with as a parameter.  

|                                                                                                                              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 unable to return a`SecondarySession`. |

### getSecondarySessionFuture

```
abstract @NonNull ListenableFuture<@NonNull SecondarySession> getSecondarySessionFuture(
    @NonNull Intent intent,
    @NonNull SecondarySessionStateCallback callback
)
```

Java-compatible version of[getSecondarySession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#getSecondarySession(android.content.Intent,com.google.ambient.crossdevice.sessions.SecondarySessionStateCallback)).  

### registerActivityResultCaller

```
abstract void registerActivityResultCaller(
    @NonNull ActivityResultCaller activityResultCaller
)
```

Registers an[ActivityResultCaller](https://developer.android.com/reference/androidx/activity/result/ActivityResultCaller)to enable Sessions to show available devices via Discovery's device launcher.  

### removeSession

```
abstract void removeSession(@NonNull SessionId sessionId)
```

Removes a Session so that it can no longer be discovered by other devices requesting transfer or share. If remove fails, a[SessionException](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionException)will be thrown.

This will cancel any ongoing requests for transfer/share ( SessionStateCallback.onTransferFailure, SessionStateCallback.onShareFailure). This will terminate any active shared sessions (Primary and Secondaries will be cleaned up -[PrimarySessionStateCallback.onPrimarySessionCleanup](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback#onPrimarySessionCleanup(com.google.ambient.crossdevice.sessions.SessionId)),[SecondarySessionStateCallback.onSecondarySessionCleanup](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SecondarySessionStateCallback#onSecondarySessionCleanup(com.google.ambient.crossdevice.sessions.SessionId))).  

### removeSessionFuture

```
abstract @NonNull ListenableFuture<Void> removeSessionFuture(@NonNull SessionId sessionId)
```

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

### shareSession

```
abstract @NonNull PrimarySession shareSession(
    @NonNull SessionId sessionId,
    @NonNull StartComponentRequest startComponentRequest,
    @NonNull List<@NonNull DeviceFilter> deviceFilters,
    @NonNull PrimarySessionStateCallback callback
)
```

Invites another device to join a Session currently running on the device this function is called on.

Opens a dialog that searches for compatible, trusted devices. When the user selects a specific device, the receiving app on that device will receive the request to join the session via[StartComponentRequest](https://developer.android.com/reference/com/google/ambient/crossdevice/wakeup/StartComponentRequest)and can begin initialization (see[SecondarySession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SecondarySession)).[StartComponentRequest](https://developer.android.com/reference/com/google/ambient/crossdevice/wakeup/StartComponentRequest)must contain an action and a user-visible reason for the request, and can optionally contain extras.

If the share cannot be initiated, a[SessionException](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionException)will be thrown.

If the receiving app is ready to accept the share request,[PrimarySessionStateCallback.onParticipantJoined](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback#onParticipantJoined(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.sessions.SessionParticipant))is triggered. Otherwise,[PrimarySessionStateCallback.onShareFailureWithParticipant](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback#onShareFailureWithParticipant(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.sessions.SessionException,com.google.ambient.crossdevice.sessions.SessionParticipant))is triggered.

Once devices are selected,[PrimarySessionStateCallback.onShareInitiated](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback#onShareInitiated(com.google.ambient.crossdevice.sessions.SessionId,kotlin.Int))will be called to inform the application of the number of potential participants.  

### shareSessionFuture

```
abstract @NonNull ListenableFuture<@NonNull PrimarySession> shareSessionFuture(
    @NonNull SessionId sessionId,
    @NonNull StartComponentRequest startComponentRequest,
    @NonNull List<@NonNull DeviceFilter> deviceFilters,
    @NonNull PrimarySessionStateCallback callback
)
```

Java-compatible version of[shareSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#shareSession(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.wakeup.StartComponentRequest,kotlin.collections.List,com.google.ambient.crossdevice.sessions.PrimarySessionStateCallback)).  

### transferSession

```
abstract @NonNull OriginatingSession transferSession(
    @NonNull SessionId sessionId,
    @NonNull StartComponentRequest startComponentRequest,
    @NonNull List<@NonNull DeviceFilter> deviceFilters,
    @NonNull OriginatingSessionStateCallback callback
)
```

Transfers a Session from the device this function is called on to another.

Opens a window that searches for compatible, trusted devices. When the user selects a specific device, the receiving app on that device will receive the request to transfer via[StartComponentRequest](https://developer.android.com/reference/com/google/ambient/crossdevice/wakeup/StartComponentRequest)and can begin initialization (see[ReceivingSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/ReceivingSession)).[StartComponentRequest](https://developer.android.com/reference/com/google/ambient/crossdevice/wakeup/StartComponentRequest)must contain an action and a user-visible reason for the request, and can optionally contain extras.

If transfer cannot be initiated, a[SessionException](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/SessionException)will be thrown.

If receiving app is ready to accept the transfer,[OriginatingSessionStateCallback.onConnected](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/OriginatingSessionStateCallback#onConnected(com.google.ambient.crossdevice.sessions.SessionId))is triggered. Otherwise,[OriginatingSessionStateCallback.onTransferFailure](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/OriginatingSessionStateCallback#onTransferFailure(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.sessions.SessionException))is triggered.  

### transferSessionFuture

```
abstract @NonNull ListenableFuture<@NonNull OriginatingSession> transferSessionFuture(
    @NonNull SessionId sessionId,
    @NonNull StartComponentRequest startComponentRequest,
    @NonNull List<@NonNull DeviceFilter> deviceFilters,
    @NonNull OriginatingSessionStateCallback callback
)
```

Java-compatible version of[transferSession](https://developer.android.com/reference/com/google/ambient/crossdevice/sessions/Sessions#transferSession(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.wakeup.StartComponentRequest,kotlin.collections.List,com.google.ambient.crossdevice.sessions.OriginatingSessionStateCallback)).