# SessionInfoIntentEncoder

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/SessionInfoIntentEncoder.java+class:androidx.car.app.SessionInfoIntentEncoder) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

*** ** * ** ***


```
public class SessionInfoIntentEncoder
```

<br />

*** ** * ** ***

Helper to encode and decode a `https://developer.android.com/reference/androidx/car/app/SessionInfo` from an `https://developer.android.com/reference/android/content/Intent.html`

## Summary

| ### Public methods |
|---|---|
| `static boolean` | `https://developer.android.com/reference/androidx/car/app/SessionInfoIntentEncoder#containsSessionInfo(android.content.Intent)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent)` Returns whether or not the given `intent` contains an encoded `https://developer.android.com/reference/androidx/car/app/SessionInfo`. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/SessionInfo` | `https://developer.android.com/reference/androidx/car/app/SessionInfoIntentEncoder#decode(android.content.Intent)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent)` Decodes a new `https://developer.android.com/reference/androidx/car/app/SessionInfo` for a given `intent` |
| `static void` | `https://developer.android.com/reference/androidx/car/app/SessionInfoIntentEncoder#encode(androidx.car.app.SessionInfo,android.content.Intent)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/SessionInfo sessionInfo, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent)` Sets the unique identifier for the given `intent` and encodes the passed `https://developer.android.com/reference/androidx/car/app/SessionInfo` in its extras. |

## Public methods

### containsSessionInfo

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public static boolean containsSessionInfo(@NonNull Intent intent)
```

Returns whether or not the given `intent` contains an encoded `https://developer.android.com/reference/androidx/car/app/SessionInfo`.

### decode

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public static @NonNull SessionInfo decode(@NonNull Intent intent)
```

Decodes a new `https://developer.android.com/reference/androidx/car/app/SessionInfo` for a given `intent`

### encode

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public static void encode(@NonNull SessionInfo sessionInfo, @NonNull Intent intent)
```

Sets the unique identifier for the given `intent` and encodes the passed `https://developer.android.com/reference/androidx/car/app/SessionInfo` in its extras.

The intent identifier that's created is unique based on `https://developer.android.com/reference/androidx/car/app/SessionInfo#toString()`. The `https://developer.android.com/reference/android/content/Intent.html` field that's set is either `https://developer.android.com/reference/android/content/Intent.html#setIdentifier(java.lang.String)` on API 29 and above, or `https://developer.android.com/reference/android/content/Intent.html#setData(android.net.Uri)`.