Sorry, you need to enable JavaScript to visit this website.

Services

Services

Services initialization

Maps SDK for Android provides users with interfaces that can be used to manage connection between devices.

To obtain access to this module you will need to add following dependency to your build.gradle file:

implementation("com.tomtom.online:sdk-connectivity-services:2.4292")

Services module gives access to ConnectivityApi interface and PriorityConnectivityApi implementation.
ConnectivityApi is used to manage connections and send data between devices. In addition it also accepts multiple communicators that will be used to send/receive data.

ConnectivityApi provides access to following methods:

  • Connect

  • Disconnect

  • Send(Command)

In order to create an instance use PriorityConnectivityApiBuilder and provide required parameters to it which are:

  • StatusHandler

  • One or more CommunicatorFactory

  • One or more CommandModule

_

ConnectivityApi connectivityApi = new PriorityConnectivityApiBuilder(context)
            .addCommunicator(communicatorFactory1)
            .addCommunicator(communicatorFactory2)
            .addModule(new CommonCommandModule())
            .withStatusHandler(statusHandler)
            .build()
val connectivityApi = PriorityConnectivityApiBuilder(context)
            .addCommunicator(communicatorFactory1)
            .addCommunicator(communicatorFactory2)
            .addModule(CommonCommandModule())
            .withStatusHandler(statusHandler)
            .build()

StatusHandler will be used by ConnectivityApi for notification of an operations status.
To achieve that implement StatusHandler interface or create an ReferenceStatusHandler in the following manner:

protected val statusHandler = ReferenceStatusHandler(
    onReadStatusReady = { communicatorInfo, status -> onReadStatusReady(communicatorInfo, status) },
    onWriteStatusReady = { communicatorInfo, status -> onWriteStatusReady(communicatorInfo, status) },
    onConnectionStatusReady = { communicatorInfo, status -> onConnectionStatusReady(communicatorInfo, status) },
    onDisconnect = { communicatorInfo -> onDisconnect(communicatorInfo) }
)

Communicators

By default, ConnectivityApi does not support any Communicator. Several communicator modules adapt
specific connection type:

  • Bluetooth SPP Server

  • Bluetooth SPP Client

  • Bluetooth Low Energy Server

  • Bluetooth Low Energy Client

You are here