Introduction to Android Wear
Let us know how you feel about this
last updated: 2017-02
With the introduction of Google's Android Wear, you are no longer restricted to just phones and tablets when it comes to developing great Android apps. Xamarin.Android's support for Android Wear makes it possible for you to run C# code on your wrist! This introduction provides a basic overview of Android Wear, describes its key features, and offers an early look at Xamarin Android Wear 2.0. It lists some of the more popular Android Wear devices, and it provides links to essential Google Android Wear documentation for further reading.
Android Wear runs on a variety of devices, including the first-generation Motorola 360, LG's G watch, and the Samsung Gear Live. A second generation, including Sony's SmartWatch 3, has also been released with additional capabilities including built-in GPS and offline music playback. For Android Wear 2.0, Google has teamed up with LG for two new watches: the LG Watch Sport and the LG Watch Style.
Xamarin.Android 5.0 and later supports Android Wear through our Android 4.4W (API 20) support and a NuGet package that adds additional Wear-specific UI controls. Xamarin.Android 5.0 and later also includes functionality for packaging your Wear apps. Preview NuGet packages are also available for Android Wear 2.0 as described later in this guide.
Android Wear Basics
Android Wear has a user interface paradigm that differs from that of Android handheld apps. The first wave of Wear apps were designed to extend a companion handheld app in some way, but beginning with Android Wear 2.0, Wear apps can be used standalone. When you deploy a Wear app, it is packaged with a companion handheld app. Because most Wear apps depend upon a handheld companion app, they need some way to communicate with handheld apps. The following sections describe these usage scenarios and outline the essential Android Wear features.
The first version of Android Wear was focused primarily on extending current handheld applications with enhanced notifications and syncing data between the handheld app and the wearable app. Therefore, these scenarios are relatively straightforward to implement.
The simplest way to support Android Wear is to take advantage of the
shared nature of notifications between the handheld and the wearable
device. By using the support v4 notification API and the
WearableExtender class (available in the
Xamarin Android Support
you can tap into the native features of the platform, like inbox
style cards or voice input. The
sample provides example code that demonstrates how to send a list
of notifications to an Android Wear device.
Another strategy is to create a complete application that runs natively on the wearable device and pairs with a companion handheld app. A good example of this approach is the Quiz sample app, which demonstrates how to create a quiz that runs on a handheld device and asks quiz questions on the wearable device.
The primary navigation pattern for Wear is a series of cards arranged
vertically. Each of these cards can have associated actions that are
layered out on the same row. The
GridViewPager class provides this
functionality; it adheres to the same adapter concept as
You typically associate the
GridViewPager with a
GridPagerAdaptor) that lets you
represent each row and column cells as a
Wear also makes use of action buttons that consist of a big colored circle
with small description text underneath it (as illustrated above). The
GridViewPager sample demonstrates
how to use
GridPagerAdapter in a Wear app.
Android Wear 2.0 adds a navigation drawer, an action drawer, and inline action buttons to the Wear user interface. For more about Android Wear 2.0 user interface elements, see the Android Anatomy topic.
Android Wear provides two different communication APIs to facilitate communications between wearable apps and companion handheld apps:
Data API – This API is similar to a synchronized data store
between the wearable device and the handheld device. Android takes care
of propagating changes between wearable and handheld when it is optimal
to do so. When the wearable is out of range, it queues synchronization
for a later time. The main entry point for this API is
WearableClass.DataApi. For more information about this API, see the
Syncing Data Items
Message API – This API makes it possible for you to use
a lower level communications path: a small payload is sent one-way
without synchronization between the handheld and wearable apps.
The main entry point for this API is
For more information about this API, see the Android
Sending and Receiving Messages
You can choose to register callbacks for receiving those messages
via each of the API listener interfaces or, alternatively,
implement a service in your app that derives from
This service will be automatically instantiated by Android Wear.
The FindMyPhone sample
illustrates how to implement a
Each wearable app is deployed with its own APK file embedded inside the main application APK. This packaging is handled automatically in Xamarin.Android 5.0 and later, but must be performed manually for versions of Xamarin.Android earlier than version 5.0. Working with Packaging explains deployment in more detail.
The best way to become familiar with Android Wear is to build and test your first app. The following list provides a recommended reading order to help you get up to speed quickly:
Installation and Setup provides detailed instructions for installing and configuring your development environment for building Xamarin.Android Wear apps.
After you have installed the required packages and configured an emulator or device, see Getting Started for step-by-step instructions that explain how to create a small Android Wear project that handles button clicks and displays a click counter on the Wear device.
Working with Screen Sizes explains how to preview and optimize your user interface for the various available screen sizes on Wear devices.
Working with Packaging describes the steps for manually packaging Wear apps for distribution on Google Play.
After you have created your first Wear app, you may want to try building a custom watch face for Android Wear. Creating a Watch Face provides step-by-step instructions and example code for developing a stripped down digital watch face service, followed by more code that enhances it to an analog-style watch face with extra features.
Android Wear 2.0
Android Wear 2.0 introduces a variety of new features and capabilities, such as complications, curved layouts, navigation and action drawers, and expanded notifications. Also, Wear 2.0 makes it possible for you to build standalone apps that work independently of handheld apps. The new wrist gestures capability enables one-handed interactions with your app. Xamarin.Android support for Wear 2.0 is still in preview, but you can install the preview packages to try out the new features.
The following sections highlight these features and provide links to help you get started with using them in your app.
Install Wear 2.0 Packages
To build a Wear 2.0 app with Xamarin.Android, you must add the Xamarin.Android.Wear v2.0 package to your project. Because this package is in prerelease, you must enable Include prelease in the Nuget Package Manager in order for this package to appear in the Browse tab search:
If you have already created a Xamarin.Android Wear project with the current stable version of Wear, the NuGet Package Manager can upgrade your project to the prelease version. This NuGet package contains bindings for both the Android Support Wearable and Wear Compat libraries.
In addition to Xamarin.Android.Wear, we recommend that you install the Xamarin.GooglePlayServices.Wearable NuGet:
Key Features of Wear 2.0
Android Wear 2.0 is the biggest update to Android Wear since its initial launch in 2014. The following sections highlight the key features of Android Wear 2.0, and links are provided to help you get started using these new features in your app.
Complications are small watch face widgets that you can see at a glance without having to swipe the watch face. Complications are similar to desktop-style dashboard widgets; they display information such as the weather, battery life, calendar events, and fitness app statistics:
For more about complications, see the Android Watch Face Complications topic.
Navigation and Action Drawers
Two new drawers are included in Wear 2.0. The navigation drawer, which appears at the top of the screen, allows users to navigate between app views (as shown on the left below). The action drawer, which appears at the bottom of the screen (as shown on the right), allows users to choose from a list of actions.
For more information about these two new interactive drawers, see the Android Wear Navigation and Actions topic.
Wear 2.0 introduces new features for displaying curved layouts on round
Wear devices. Specifically, the new
WearableRecyclerView class is
optimized for displaying a list of vertical items on round displays:
WearableRecyclerView extends the
RecyclerView class to support
curved layouts and circular scrolling gestures. For more information,
see the Android
Android Wear 2.0 apps can work independently of handheld apps. This means that, for example, a smart watch can continue to offer full functionality even if the companion handheld device is turned off or far away from the wearable device. For more information about this feature, see the Android Standalone Apps topic.
Wrist gestures make it possible for users to interact with your app without using the touch screen – users can respond to the app with a single hand. Two wrist gestures are supported:
- Flick wrist out
- Flick wrist in
For more information, see the Android Wrist Gestures topic.
There are many more Wear 2.0 features such as inline actions, smart reply, remote input, expanded notifications, and a new bridging mode for notifications. For more information about the new Wear 2.0 features, see the Android API Overview.
Here are some examples of the devices that can run Android Wear:
Check out Google's Android Wear documentation:
This introduction provided an overview of Android Wear. It outlined the basic features of Android Wear and included a preview of the new features available in Android Wear 2.0. It provided links to essential reading to help developers get started with Xamarin.Android Wear development, and it listed examples of some of the Android Wear devices currently on the market.