Android Wear Projects

2 (1 reviews total)
By Ashok Kumar S
  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Getting You Ready to Fly - Setting Up Your Development Environment

About this book

Android Wear Projects is your opportunity to step into the exciting new world of Android Wear app development. This book will help you to master the skills in Android Wear programming and give you a complete insight on wear app development.

You will create five different Android Wear apps just like the most popular Android Wear apps. You will create a To-do list, a city maps app, a Wear messenger, Wear fitness tracker and Watch face. While you create these apps you will learn to create custom notifications, receive voice inputs in notifications, add pages to notifications and stack notifications. You will see how to create custom wear app layouts, the custom UIs specially designed for Wear. You will learn to handle and manage data and syncing data with other devices, create interactive Watch faces and also ensure the safety and security of your Wear apps by testing and securing your apps before you deploy them on the app store.

Publication date:
July 2017


Chapter 1. Getting You Ready to Fly - Setting Up Your Development Environment

The culture of Wearing a utility that helps us to perform certain actions has always been part of a modern civilization. Wrist watches for human beings have become an augmented tool for checking the time and date. Wearing a watch lets you check the time with just a glance. Technology has taken this watch-wearing experience to the next level. The first modern Wearable watch was a combination of a calculator and a watch, introduced to the world in 1970. Over the decades, advancements in microprocessors and wireless technology have led to the introduction of a concept called ubiquitous computing. During this time, most leading electronics industry start-ups started to work on their ideas, which has made Wearable devices very popular.

Tech giant companies, such as Google, Apple, Samsung, and Sony, have joined the force of the Wearable devices era. They have introduced their competitive Wearable products, which are extremely successful in the Wearable device market. More interestingly, Google's Android Wear is powerful, follows the same Android smartphone development practices, and has a very good developer community compared to Apple Watch OS and Samsung's Tizen OS developer community.

Google announced Android Wear in March 2014. Since then, Android Wear as a smartwatch and Wearable software platform has evolved. Google's continuous advancement in designing and user experience have resulted in a new generation of the Android Wear operating system, which has the ability to handle biometric sensors like never before with more features in the platform; Google calls it Android Wear 2.0.

Android Wear 2.0 will cause a lot of excitement in app development with remarkably competitive features to develop. Android Wear 2.0 allows a developer to build and carve his idea specific to Android Wear; there is no need to pair a watch and mobile app. Google calls it a standalone application. Android Wear 2.0 introduces a new way to input within the Android watch: a new application programming interface called Complications, which allows watch faces to display vital information from biometrics and other sensors. New updated notifications support for Android Wear 2.0 will help users and developers to present notifications in a more comprehensive manner.

In this chapter, we will explore the following:

  • Android Wear design principles
  • Exploring essential UI components specific to Wear apps
  • Setting up a development environment for Wear apps development
  • Creating your first Android Wear application

Android Wear design principles

Designing a Wear is different than a mobile or tablet application. The Wear operating system is very lightweight and has a specific set of jobs to accomplish by sharing the right information with the Wearer.

General Wear principles are Timely, Glanceable, Easy to Tap, Time-Saving.


Giving the right information at the right time.


Keeping the Wear application user interface clean and uncluttered.

Easy to Tap

The actions users will click on should have the right spacing and size of the picture.


Creating the best application flows that do tasks quickly.

For any Wear application, we need the proper building blocks to control the business logic of the application and other architectural implementation. The following are the scenarios for developing a Wear application to help us to carve the wear application better:

  • Defining layouts
  • Creating lists
  • Showing confirmations
  • Wear navigation and actions
  • Multifunction buttons

Defining layouts

Wearable can use the same layouts that we use in handheld Android device programming but with specific constraints for Wear applications. We should not do heavy processing actions similar to handheld Android devices in Wear applications and expect a good user experience.

An application designed for a round screen will not look great on square Wear devices. To resolve this, the Android Wear support library comes with the following two solutions:

  • BoxInsetLayout
  • Curved Layout

We can provide different resources to allow Android to detect the shape of the Android Wear at runtime.

Creating lists

Lists let the user an item from a set of items. In the legacy Wear, 1.x API WearableListView helped programmers to build lists and custom lists. Wearable UI library now has WearableRecyclerView with curvedLayout support and has the best implementation experience in Wear devices.

We can add gestures and other magnificent functionalities:


Exploring UI components for Wear devices

In this subchapter, let's explore the used Wear-specific UI components. In Wear application programming, we can use all the components that we use in mobile app programming, but how we accommodate the visual appearance of components in the Wear device needs to be well thought of before using it.

WatchViewStub: WatchViewStub helps in rendering the views for different form factors of Wearable devices. If your application is being installed on a round watch device, WatchViewStub will load the specific layout configuration for round watches. If it is square, it will load the square layout configuration:

<?xml version="1.0" encoding="utf-8"?>
< xmlns:android=""

WearableRecyclerView: WearableRecyclerView is the implementation of recyclerview specific to wearable devices. It provides a flexible view for datasets in the Wearable device viewport. We will explore WearbaleRecyclerView in detail in the coming chapters:

   android:scrollbars="vertical" /> 


Note:WearableListView is deprecated; the Android community recommends using WearableRecyclerView.

CircledImageVIew: An Imageview surrounded by a circle. A very handy component for presenting the image in round form factor Wearable devices:

<?xml version="1.0" encoding="utf-8"?>
    android:layout_height="wrap_content" />

BoxInsetLayout: This Layout directly to Framelayout and it has the ability to recognize the form factor of the Wearable device. Shape-aware FrameLayout can box its children in the center square of the screen:

<    xmlns:android=""

    app:layout_box="all" />


After the Wear 2.0 release, a few components were deprecated for an immersive activity experience and Google strictly prohibits using them; we can still use all the components that we know in Android programming.

Showing confirmations

Compared to in handheld Android devices, in Wear applications, confirmations should occupy the whole screen or more than what handheld devices show as a dialogue box. This ensures users can see these confirmations at one glance. The Wearable UI library helps in displaying confirmation timers and animated timers in Android Wear.


A DelayedConfirmationView is an confirmation view based on the timer:


Wear navigation and actions

In the new of Android Wear, the Material design library the following two interactive drawers:

  • Navigation drawer
  • Action drawer

Navigation drawer

Lets user switch between in the application. Developers can allow the drawer to be opened anywhere within the scrolling parent's content by setting the setShouldOnlyOpenWhenAtTop() method to false:


Action drawer

The action drawer gives to easy and common actions in your application. By default, action drawer appears at the bottom of the screen and provides specific actions to users:


Multifunction buttons

In addition to the power button, Android Wear supports another button called the multifunction button on the device. The Wearable library provides API for determining the multifunction buttons included by the manufacturer:

// Activity
publicboolean onKeyDown(int keyCode,KeyEventevent){
if(keyCode ==KeyEvent.KEYCODE_STEM_1){
// Do stuff
}elseif(keyCode ==KeyEvent.KEYCODE_STEM_2){
// Do stuff
}elseif(keyCode ==KeyEvent.KEYCODE_STEM_3){
// Do stuff

Visit for any sort of query that you might have on design guidelines for Wear device programming.


Setting up a development environment for Wear development

In this section, we set up a development environment for Wear development.


  1. Your favorite operating system (Windows, macOS, or Linux)
  2. Determine whether you have the latest JRE installed on your operating system
  3. Install the latest version of JDK or Open JDK
  4. Install the latest version of Android Studio (at the time of writing this book, the latest version is 2.2.3 and any newer version should be fine)

Installing Android Studio

Visit to download the latest version of Android Studio. Google highly recommends using Android Studio for all Android application development, since Android Studio has tight with and useful Android APIs:

After the Android Studio installation, it's now time to download the necessary SDK in the SDK Platforms tab in SDK Manager. Install one complete version of Android; for the scope of this book, we will install Android 7.1.1 API level 25:

After the successful installation of the SDK of Nougat 7.1.1 API level 25, under the SDK Tools tab, make sure you have the components, as shown in the following screenshot:

  • Android Support Library
  • Google Play services
  • Google Repository
  • Android Support Repository

Google releases updates on IDE and SDK Tools frequently; keep your development environment up-to-date.


Note: if you plan to make your application available in China, then you must use the special release version 7.8.87 of the Google Play services client library to handle communication between a phone and watch:

Visit the following link to check the Release Notes on SDK Tools:

Updating your IDE from the stable channel is highly recommended. Updates for Android Studio are available on four different channels:

  • Canary channel
  • Dev channel
  • Beta channel
  • Stable channel

Canary channel: The Android Studio team works continuously to make Android Studio better. In this channel, every week there will be an update release, and it will include new functionality changes and improvements; you can check those changes in the release notes. But updates from this channel are not recommended for application production.

Dev Channel: On this channel, a happens after a complete round of internal testing from the Android Studio team.

Beta channel: On this channel, updates are based on stable Canary builds. Before publishing these builds to a stable channel, Google releases them in the beta channel to get developer feedback.

Stable Channel: Are the official stable releases of the Android Studio and will be available to download on Google's page

By default, Android Studio receives from a stable channel.


Creating your first Android Wear application

In this section, let's understand the steps required to create your first Wear project.


Before you continue to create your application, ensure you have one complete version of Android installed with a Wear system image and you have the latest version of Android Studio.

The following picture is the initial interface of Android Studio. In this window, one can import legacy ADT Android projects, configure the Android SDK, and update Android Studio.

Android Studio welcome window with basic controls for getting started:

Creating your first Wear project

Click on the Start a new Android Studio project option in the Android Studio window. You will be prompted by another with project details.

The following screenshot shows the window that allows users to configure their project details, such as project name, Package name, and whether the project needs native C++ support:

You can name your project as you wish. After you have chosen your project name and your project local system location, you can press the Next button in the window, which brings up another window with a few queries, as shown in the following screenshot:

In this window, you can choose to write a standalone Wear application if you uncheck the Phone and Tablet option. In way, you will see only Wear application templates:

Now, Android Studio templates prompt only Android Wear activity templates with the following set of options:

  • Add No Activity
  • Always On Wear Activity
  • Blank Wear Activity
  • Display Notification
  • Google Maps Wear Activity
  • Watch Face

The activity template helps you to access the default boilerplate codes, which are already templatized and can be used directly in projects:

To create the first project, we will choose Blank Wear Activity and click on the Next button in the window. Android Studio will prompt another window for creating the name of the activity and layout file. In this template, the two form factors of Android Wearable devices, which are mostly round and square shapes, are with the boilerplate code stub:

When your project is ready to be created, click on the Finish button. After clicking on Finish, Android Studio will take a few moments to create the project for us.

Way to go! You have now created a working boilerplate code for the Android Wear standalone application without the phone companion application. When successfully created, you will see the following files and codes to your project by default:

If your SDK is not updated with API level 25, you might see the Wear option in the Android Studio project creating prompts with Android Wear support library 1.x; you can update this in the Wear module Gradle file with the following dependency:

compile ''

Creating a Wear emulator

The process of a Wear emulator is very to creating a phone emulator.

In the AVD manager, click on the Create Virtual Device... button:

Choose the required form factor emulator according to your application needs. Now, let's create the Android Wear square emulator:

After selecting the right emulator for your Wear, you will get another prompt to choose the Wear operating system. Let's the API Level 25Nougat emulator, as in the following screenshot:

The last prompt asks for the emulator name and other orientation configurations based on your needs:

Way to go! Now, we have successfully created a square form emulator for the project. Let's run the project that we have in the emulator:

Google recommends developing Wear apps in the actual hardware device to have the best user experience. However, working on emulators has the benefit of creating different screen form factors to check the application's rendering.

Working with actual Wear device
  1. Open the settings on the Wear device
  2. Go to About device
  3. Click on the build number seven times to enable developer mode
  4. Now enable ADB debugging on the watch

You can now connect the Wear device directly to your machine with the USB cable. You can debug your applications over Wi-Fi and Bluetooth with the following setups.

Debugging over Wi-Fi

Make sure your watch has the options enabled. Debugging over Wi-Fi is possible only when the Wear device and machine are connected to the same network.

  • In the Wear device developer option, tap on Debug over Wi-Fi
  • The watch will display its IP address (for example, Keep a reference; we need this for the next step.
  • Connect the debugger to the device
  • Using the following command, we can attach the actual device to the ADB debugger:
adb connect
Enable Bluetooth debugging

We need to ensure debugging is in developer options, as follows:

adb forward tcp:4444 localabstract:/adb-hub
adb connect

In your Android Wear, just allow ADB Debugging when it asks.

Now that we have a working setup of our development environment, let's understand the basic Android Wear-specific UI components.



In this chapter, we have looked at the initial setup for Wear application development. We have understood the necessary components to download, setting up a Wear emulator, connecting the Wear emulator to the ADB bridge, debugging over Wi-Fi, and essential user interface components specific to Wear development. In the next chapter, we will explore how to build a note-taking application which persists the data that users enter.


About the Author

  • Ashok Kumar S

    Ashok Kumar S has been working in the mobile development domain from about eight years. He is a Google certified engineer, speaker at global scale conferences and he also runs a youtube channel (AndroidABCD) for Android developers. He is an early Firebase adopter since before Google acquired Firebase.

    He is Computer Science and Engineering graduate who is completely passionate about innovation in technology. He contributes to open source heavily to improve his e-karma. Ashok has also written a book on Wear OS programming through a project approach.

    Browse publications by this author

Latest Reviews

(1 reviews total)
The book is not updated. All projects needs revisiting and take a lot of time to make things work. They shouldn't sell it anymore, or they could make an upgrade.