DtdiClient

 @DoNotMock 
 ( 
"Use canonical fakes instead." ) 
 interface 
 DtdiClient 
 : 
  HasApiKey 
 
 < 
  NoOptions 
 
 > 

A client for the DTDI Discovery API

Summary

Public methods

abstract Task < Void >
closeConnection ( channelInfo : ChannelInfo , token : IBinder , closeReason : String ? )

Closes the connection.

abstract Task < Void >

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.

abstract Task < Void >
registerPayloadReceiver ( channelInfo : ChannelInfo , token : IBinder , onPayloadReceivedCallback : OnPayloadReceivedCallback )

Registers a payload receiver to receive payload from a named channel on a remote device.

abstract Task < Void >
sendPayload ( channelInfo : ChannelInfo , token : IBinder , bytes : ByteArray )

Sends raw bytes to a remote device over a named channel.

abstract Task < Void >
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.

abstract Task < Void >

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.

Parameters
channelInfo : ChannelInfo
a tuple of channel name and channel type that can uniquely identify a channel on the app.
token : IBinder
A token for a remote device from SelectedDevice .
closeReason : String ?
An optional reason to indicate to the remote device the reason for closing.
Return
for the operation. Task failures are sent out as ApiException with CommonStatusCodes .

closeDevice

 abstract 
 fun 
 closeDevice 
 ( 
 token 
 : 
  IBinder 
 
 ) 
 : 
  Task 
 
 < 
  Void 
 
 > 

Closes the device. Devices previously returned from SelectedDevice should be closed to free any resources used.

Parameters
token : IBinder
A token for the remote device from SelectedDevice.token .

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:

Parameters
deviceFilters : List < DeviceFilter >
Only devices that pass all filters will be shown to the user.
allowMultipleDeviceSelection : Boolean
Whether or not to allow selecting multiple devices.
wakeupRequest : WakeUpRequest
The request used to indicate the activity or component to wake up on the receiving device.
parentCorrelationData : CorrelationData ?
A parent correlation data to correlate multiple invocations of this method, or null for calls not part of a larger experience.
devicePickerTheme : Int =  DevicePickerTheme.DEFAULT
The theme of device picker.
Return
with the IntentSender for the device picker.

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 .

getApiAvailability

 abstract 
 fun 
 getApiAvailability 
 ( 
 ) 
 : 
  Task 
 
 < 
  ApiAvailability 
 
 > 

Returns information about the availability of DTDI API.

Return
for the operation. Task failures are sent out as ApiException with CommonStatusCodes .

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.

Parameters
channelInfo : ChannelInfo
a tuple of channel name and channel type that can uniquely identify a channel on the app.
token : IBinder
A token for a remote device from SelectedDevice .
onPayloadReceivedCallback : OnPayloadReceivedCallback
The callback to call when a payload is received.
Return
for the operation. Task failures are sent out as ApiException with CommonStatusCodes .

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.

Parameters
channelInfo : ChannelInfo
a tuple of channel name and channel type that can uniquely identify a channel on the app.
token : IBinder
A token for a remote device from SelectedDevice .
bytes : ByteArray
Byte array to send to the remote device.
Return
for the operation. Task failures are sent out as ApiException with CommonStatusCodes .

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.

Return
for the operation. Task failures are sent out as ApiException with CommonStatusCodes .

stopScanningForDeviceAvailability

 abstract 
 fun 
 stopScanningForDeviceAvailability 
 ( 

listener : DeviceAvailabilityListener ,
parentAnalyticsInfo : AnalyticsInfo ? =  null
) : Task < Void >

Stop scanning for devices availability.

Return
for the operation. Task failures are sent out as ApiException with CommonStatusCodes .

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.

Create a Mobile Website
View Site in Mobile | Classic
Share by: