DtdiClient
@DoNotMock ( "Use canonical fakes instead." ) interface DtdiClient : HasApiKey < NoOptions >
A client for the DTDI Discovery API
Summary
Public methods
closeConnection
( channelInfo
:
ChannelInfo
, token
:
IBinder
, closeReason
:
String
?
)
Closes the connection.
closeDevice
( token
:
IBinder
)
Closes the device.
createDevicePickerIntent
( deviceFilters
:
List
<
DeviceFilter
>
, allowMultipleDeviceSelection
:
Boolean
, wakeupRequest
:
WakeUpRequest
, parentCorrelationData
:
CorrelationData
?
, devicePickerTheme
:
Int
=
DevicePickerTheme.DEFAULT)
Creates an IntentSender for a device picker that allows the user to select one or more devices matching the given device filter.
createDevicePickerIntent
( deviceFilters
:
List
<
DeviceFilter
>
, allowMultipleDeviceSelection
:
Boolean
, wakeupRequest
:
WakeUpRequest
, parentCorrelationData
:
CorrelationData
?
)
Creates an IntentSender for a device picker with the theme DevicePickerTheme.DEFAULT .
Returns information about the availability of DTDI API.
registerPayloadReceiver
( channelInfo
:
ChannelInfo
, token
:
IBinder
, onPayloadReceivedCallback
:
OnPayloadReceivedCallback
)
Registers a payload receiver to receive payload from a named channel on a remote device.
sendPayload
( channelInfo
:
ChannelInfo
, token
:
IBinder
, bytes
:
ByteArray
)
Sends raw bytes to a remote device over a named channel.
startScanningForDeviceAvailability
( deviceFilters
:
List
<
DeviceFilter
>
?
, listener
:
DeviceAvailabilityListener
, feature
:
Int
, parentAnalyticsInfo
:
AnalyticsInfo
?
=
null)
Begin scanning for devices availability, given a set of filters and a client feature.
stopScanningForDeviceAvailability
( listener
:
DeviceAvailabilityListener
, parentAnalyticsInfo
:
AnalyticsInfo
?
=
null)
Stop scanning for devices availability.
Companion functions
getDevicesResultFromActivityResult
( @IntRange
(
-1 )
resultCode
:
Int
, resultData
:
Intent
)
Returns the GetDevicesResult object stored in the result data.
Public methods
closeConnection
abstract fun closeConnection (
channelInfo : ChannelInfo ,
token : IBinder ,
closeReason : String ?
) : Task < Void >
Closes the connection. Stop receiving payloads from a named channel on a remote device. The OnPayloadReceivedCallback that previously passed to registerPayloadReceiver will be unregistered.
closeDevice
abstract fun closeDevice ( token : IBinder ) : Task < Void >
Closes the device. Devices previously returned from SelectedDevice should be closed to free any resources used.
createDevicePickerIntent
abstract fun createDevicePickerIntent (
deviceFilters : List < DeviceFilter > ,
allowMultipleDeviceSelection : Boolean ,
wakeupRequest : WakeUpRequest ,
parentCorrelationData : CorrelationData ? ,
devicePickerTheme : Int = DevicePickerTheme.DEFAULT
) : Task < IntentSender >
Creates an IntentSender for a device picker that allows the user to select one or more devices matching the given device filter.
The calling app should start IntentSender with startIntentSenderForResult and if the result code is RESULT_OK , get the list of devices from the result data.
The result data bundle contains the following fields:
- DtdiClient.RESULT_DEVICES_KEY : GetDevicesResult s for the user selection.
null
for calls not part of a larger experience.createDevicePickerIntent
abstract fun createDevicePickerIntent (
deviceFilters : List < DeviceFilter > ,
allowMultipleDeviceSelection : Boolean ,
wakeupRequest : WakeUpRequest ,
parentCorrelationData : CorrelationData ?
) : Task < IntentSender >
Creates an IntentSender for a device picker with the theme DevicePickerTheme.DEFAULT .
See Also
getApiAvailability
abstract fun getApiAvailability ( ) : Task < ApiAvailability >
Returns information about the availability of DTDI API.
registerPayloadReceiver
abstract fun registerPayloadReceiver (
channelInfo : ChannelInfo ,
token : IBinder ,
onPayloadReceivedCallback : OnPayloadReceivedCallback
) : Task < Void >
Registers a payload receiver to receive payload from a named channel on a remote device. If the given channel already has a receiver, an ApiException with DEVELOPER_ERROR will be thrown.
sendPayload
abstract fun sendPayload (
channelInfo : ChannelInfo ,
token : IBinder ,
bytes : ByteArray
) : Task < Void >
Sends raw bytes to a remote device over a named channel. If the named channel doesn't exist, it will be created before sending the first payload.
startScanningForDeviceAvailability
abstract fun startScanningForDeviceAvailability (
deviceFilters : List < DeviceFilter > ? ,
listener : DeviceAvailabilityListener ,
feature : Int ,
parentAnalyticsInfo : AnalyticsInfo ? = null
) : Task < Void >
Begin scanning for devices availability, given a set of filters and a client feature. Only scanning for same GAIA devices is supported right now.
stopScanningForDeviceAvailability
abstract fun stopScanningForDeviceAvailability (
listener : DeviceAvailabilityListener ,
parentAnalyticsInfo : AnalyticsInfo ? = null
) : Task < Void >
Stop scanning for devices availability.
Companion functions
getDevicesResultFromActivityResult
fun getDevicesResultFromActivityResult (
@IntRange ( -1 ) resultCode : Int ,
resultData : Intent
) : GetDevicesResult ?
Returns the GetDevicesResult object stored in the result data. The result data passed to this method should be returned from DevicePickerActivity.