API reference

SpecificDeviceSelector Class

Modifiers: final
A device selector that always selects a specific, predetermined device. Use this when you want to target operations to a particular device by its identifier, such as when you have multiple devices paired and want to explicitly control which one receives commands or streams data.
Unlike AutoDeviceSelector, this selector only emits the specified device when it's present in the available device set, and null when it is removed. It does not automatically switch to other devices.
Example:
// Get a specific device from the connected devices
val devices = Wearables.devices.value
val targetDevice = devices.firstOrNull { deviceId ->
    Wearables.devicesMetadata[deviceId]?.value?.name == "My Glasses"
}
// Create session targeting that specific device
targetDevice?.let { device ->
    val session = Wearables.createSession(
        SpecificDeviceSelector(device)
    )
}

See Also

Signature

class SpecificDeviceSelector(selectedDevice: DeviceIdentifier) : DeviceSelectorBase

Constructors

SpecificDeviceSelector ( selectedDevice )
Signature
constructor(selectedDevice: DeviceIdentifier)
Parameters
selectedDevice: DeviceIdentifier  The identifier of the device to always select

Methods

activeDevice ()
Returns the selected device if it is present in either the live device set or the device metadata map, and is currently connected. This override handles emulator-connected devices that appear in metadata but not in the live Bluetooth device set, and also addresses the timing gap where the async flow collection may not have emitted yet at construction time.
Signature
open override fun activeDevice(): DeviceIdentifier?
activeDeviceFlow ()
Returns a Flow that emits the currently selected device identifier, or null when no device is selected.
Use this to reactively observe device selection changes. The flow emits whenever the selected device changes — for example, when a device connects, disconnects, or when the selector switches to a different device.
Signature
open override fun activeDeviceFlow(): Flow<DeviceIdentifier?>
Returns
Flow<DeviceIdentifier?>  A Flow of DeviceIdentifier representing the active device, or null when no suitable device is available