when matching to handle all error variants.
session.errors.collect { error ->
when (error) {
SessionError.DEVICE_DISCONNECTED -> showReconnectPrompt()
SessionError.DEVICE_POWERED_OFF -> showDeviceOffMessage()
SessionError.SESSION_ENDED_BY_DEVICE -> showSessionEndedMessage()
else -> showGenericError(error.description)
}
}
enum SessionError : Enum<SessionError> , DatError
| Member | Description |
|---|---|
NOT_INITIALIZED |
The SDK has not been initialized. Call Wearables.initialize before creating sessions.
|
NO_ELIGIBLE_DEVICE |
No connected and compatible device was found matching the provided device selector.
|
SESSION_ALREADY_STOPPED |
The operation was called on a session that has already been stopped.
|
SESSION_IDLE |
The operation was called on a session that is still idle (not yet started).
|
CAPABILITY_ALREADY_ADDED |
A capability of this type has already been added to the session.
|
CAPABILITY_NOT_FOUND |
No capability of this type exists on the session to remove.
|
DEVICE_DISCONNECTED |
The device disconnected unexpectedly during an active session.
|
DEVICE_POWERED_OFF |
The device was powered off during an active session.
|
SESSION_ENDED_BY_DEVICE |
The session was ended by the device (e.g., device-initiated stop).
|
SESSION_ALREADY_EXISTS |
The session already exists and is active for the device.
|
UNEXPECTED_ERROR |
An unexpected error occurred during the session.
|
description
: String
[Get] |
Human-readable description of the error
Signature
open override val description: String |
getLocalizedDescription
(
context
)
|
Returns a localized description of the error using Android string resources when available.
Signature
open override fun getLocalizedDescription(context: Context?): String Parameters context: Context?
Optional Android context for accessing string resources. If null or if no localized string is available, returns the default SessionError.description.
Returns String
The localized error description, or the default description if localization unavailable.
|