Scroll Essential Android 2.3 Manual de usuario Pagina 29

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 47
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 28
CHAPTER 6
Data Layer Messages
By Michael Hahn, January 2015
An application that runs on a wearable device usually utilizes some of the capabilities of a paired handheld device.
This means you need two separate Android apps, one that runs on the wearable and another that runs on the handheld.
These two apps communicate with one another over the bluetooth link that connects the two devices.
Google Play services Version 5 and later include a Wearable Message API that provides access to the data layer of a
data communications link between the two devices. Messages or data move down the protocol stack on the sending
side, across the bluetooth link, then up the stack on the receive side. The following diagram shows how a simple
message flows through the wearable communications link.
In this example, a handheld sends a message to a wearable using the sendMessage method of the Wear-
able.MessageApi. On the receiving side, a WearableListenerService monitors the data layer and invokes the on-
MessageReceived callback when a message arrives. The listener service then performs some application-specific task
based on the received message. The WearableListenerService is not the only way to receive data, but it is easy to
implement because Android Wear manages its life-cycle.
6.1 First Wearable Message
If you have not already done so, Create a Project. The new project wizard in Android Studio creates a project with two
main activities, one for the handheld device and another for the wearable. These two activities use the same package
25
Vista de pagina 28
1 2 ... 24 25 26 27 28 29 30 31 32 33 34 ... 46 47

Comentarios a estos manuales

Sin comentarios