Communicating with wearables
Wearable apps provide a great way to extend handheld devices; however, sometimes, a wearable is not powerful enough to perform a task on its own, or it needs information from the handheld.
Getting ready
As we are going to be communicating between the devices using Google Play services, we need to install the Xamarin.GooglePlayServices.Wearable NuGet before we start.
How to do it...
Apps running on wearables can communicate with apps running on the handheld devices using the Google Play services. To implement data communication between the handheld and the wearable, we can actually use the same code:
- We are going to make use of the Google Play services' Data API to synchronize data between the devices. First, we need to implement the
IDataApiDataListener
interface in our activity:public class MainActivity : Activity, IDataApiDataListener { public void OnDataChanged(DataEventBuffer dataEvents) { } }
- Then, we need to create an instance of the Google Play services...