object Wearables
devices
: StateFlow<Set<DeviceIdentifier>>
[Get] |
A StateFlow that provides the devices that can be potentially used by the Wearables SDK.
Signature
val devices: StateFlow<Set<DeviceIdentifier>> |
devicesMetadata
: Map
[Get] |
A map from DeviceIdentifier to StateFlow that provides device metadata.
Signature
val devicesMetadata: Map |
registrationState
: StateFlow<RegistrationState>
[Get] |
A StateFlow that provides the current registration state of the application with AI glasses.
Signature
val registrationState: StateFlow<RegistrationState> |
checkPermissionStatus
(
permission
)
|
Checks whether the specified device permission is granted on any linked device.
Since permissions are managed via constellation, this function returns the first valid permission grant state found among the linked devices.
Signature
suspend fun checkPermissionStatus(permission: Permission): DatResult<PermissionStatus, PermissionError> Parameters Returns DatResult
Result.success with PermissionStatus.Granted or PermissionStatus.Denied, or Result.error with PermissionError if an error occurs
|
createSession
(
deviceSelector
)
|
Creates a new session for a device matching the provided selector.
The device is resolved eagerly against the current Wearables.devices snapshot. If no connected and compatible device matches, SessionError.NO_ELIGIBLE_DEVICE is returned. If an active (non- stopped) session already exists SessionError.SESSION_ALREADY_EXISTS is returned. (singleton-per-device guarantee).
The returned session starts in DeviceSessionState.IDLE. Call Session.start to begin connecting to the device.
Example:
val session = Wearables.createSession(AutoDeviceSelector()).getOrElse { error ->
showError(error.description)
return
}
session.start()
Signature
fun createSession(deviceSelector: DeviceSelector): DatResult<Session, SessionError> Parameters |
getDeviceSessionState
(
deviceIdentifier
)
|
Gets the session state for a specific device.
Signature
fun getDeviceSessionState(deviceIdentifier: DeviceIdentifier): StateFlow<SessionState> Parameters Returns StateFlow<SessionState>
StateFlow providing the session state for the specified device
|
initialize
(
context
)
|
Initializes the Wearables SDK with the provided context. This method must be called before using any other SDK functionality.
Signature
fun initialize(context: Context): DatResult<Unit, WearablesError> Parameters context: Context
The Android context used to initialize the SDK
Returns DatResult |
reset
()
|
Resets the Wearables SDK instance.
Signature
fun reset() |
startRegistration
(
activity
)
|
Initiates the registration process with AI glasses.
This method opens the Meta AI app where the user completes the registration flow. When the user completes the flow, the result will be automatically processed and the registration state will be updated.
The Wearables.registrationState will be updated throughout the registration process.
Signature
fun startRegistration(activity: Activity) Parameters activity: Activity
The Android activity used to start the registration activity
|
startStreamSession
(
context
, deviceSelector
, streamConfiguration
)
DeprecatedUse session.addStream(streamConfiguration) on a Session created via Wearables.createSession() |
Creates and starts a new streaming session with the specified device selector and configuration.
The session is automatically started and will attempt to connect to the device selected by the device selector. Video frames are delivered through the StreamSession.videoStream Flow.
Signature
fun Wearables.startStreamSession(context: Context, deviceSelector: DeviceSelector, streamConfiguration: StreamConfiguration = StreamConfiguration()): StreamSession Parameters context: Context
The Android context for the streaming session
streamConfiguration: StreamConfiguration
The configuration for the streaming session (optional, defaults to default configuration)
|
startUnregistration
(
activity
)
|
Initiates the unregistration process with AI glasses.
This method opens the Meta AI app where the user completes the unregistration flow. When the user completes the flow, the result will be automatically processed and the registration state will be updated.
The Wearables.registrationState will be updated throughout the unregistration process.
Signature
fun startUnregistration(activity: Activity) Parameters activity: Activity
The Android activity used to start the registration activity
|
private val permissionsResultLauncher =
registerForActivityResult(Wearables.RequestPermissionContract()) { result ->
// Handle the permission result
when (result) {
PermissionStatus.GRANTED -> // Permission granted
PermissionStatus.DENIED -> // Permission denied
}
}
class RequestPermissionContract
RequestPermissionContract
()
|
Signature
constructor() Returns Wearables.RequestPermissionContract |
createIntent
(
context
, permission
)
|
Signature
open fun createIntent(context: Context, permission: Permission): Intent Parameters context: Contextpermission: PermissionReturns Intent |
getSynchronousResult
(
context
, input
)
|
Signature
open fun getSynchronousResult(context: Context, input: Permission): SynchronousResult<DatResult<PermissionStatus, PermissionError>>? Parameters context: Contextinput: PermissionReturns SynchronousResult<DatResult<PermissionStatus, PermissionError>>? |
parseResult
(
resultCode
, intent
)
|
Signature
open fun parseResult(resultCode: Int, intent: Intent?): DatResult<PermissionStatus, PermissionError> Parameters resultCode: Intintent: Intent?Returns DatResult |