The LG QPair SDK provides APIs for communicating with the paired device using LG QPair. All the APIs work on the QPair connection. The QPair connection can be established by turning on QPair on the phone and tablet, and then connecting the devices via Bluetooth.
Once two devices are paired, the QPair connection is active until the user turns off QPair on one of the devices or establishes a new connection with another device.
Paired devices consists of the local device and the peer device. The subject of actions is the local device, and the object of the actions is the peer device. In this document, we use ‘paired devices’ to indicate both devices, and use ‘local’ or ‘peer’ to indicate a certain device.
With QPair APIs, developers can send messages from the local device to the peer device when the devices are paired. In the LG QPair SDK, we call these messages Peer Intents.
To make an application for communicating between paired devices via QPair, the first thing to do is to check the QPair connection. Then put the data into Peer Intents and send them to the peer device.
From the point of view of the SDK, QPair is a service that provides notification of the QPair status and relays data between paired devices. All applications using QPair need to bind to the service. Permission for the service needs to be declared in the manifest file. Detailed code is provided in Key Implementations.
The QPair service provides an environment for communication between paired devices. The service creates Peer Intents in the local device and transmits them to the peer device. If the application sets a callback to confirm the transmission, a failure message will be sent within the callback, which is also a Peer Intent, if the transmission fails. The callback Peer Intent will describe the cause of failure, e.g. connection problem.
Things You Can Do with QPair APIs
LG QPair APIs allow applications to communicate with the peer device through the QPair connection. The key features of the LG QPair SDK are described in LG QPair SDK Overview. This chapter will discuss what you can do with the APIs.
Controlling peer device
Peer Intents can contain commands because they are similar to Android Intents. Peer Intents can therefore control the peer device by running an application, changing the wallpaper, or opening a URI, for example.
Sending files to peer device
Peer Intents can contain text or binary files. developers must use the special API for sending files.
Sharing properties between paired devices
LG QPair supports a logical shared area between paired devices. In this area, the properties consisting of information that can be accessed by both the local device and the peer device are stored. If a property is changed on the local device, the value is copied to the peer device if the connection is established. The QPair service is responsible for synchronizing the properties.
Receiving QPair status
The QPair service broadcasts the QPair status. All applications that register a broadcast receiver for them can receive broadcast intents from the QPair service. A list of QPair broadcast intents is provided in Key Implementations.