Collecting sensor data from Wear devices needs a mechanism, and the Wearable DataLayer API, which is part of the Google Play services, plays a major role in the communication process. We will explore the communication process in later lessons but in this chapter, we need to receive the sensor data in the mobile app. We have created the project, which already has a mobile module and the simple plain old Hello World boilerplate code. We will work on the mobile module once we set our data sending mechanism from the Wear app. Let's start with the step count sensor in the services package of the Wear module and go to the WearStepService
class. We have built this service to fire a notification and listen to the step counter data. Now, with the help of GoogleApiClient
and the Wear Messaging API, we need to send the data to the mobile app.
In the WearStepService
class, instantiate GoogleApiClient
in the global scope of the class:
GoogleApiClient mGoogleApiClient;
In...