Book Image

Android Wear Projects

By : Ashok Kumar S
Book Image

Android Wear Projects

By: Ashok Kumar S

Overview of 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.
Table of Contents (18 chapters)
Title Page
About the Author
About the Reviewers
Customer Feedback
Let us Help Capture What is on Your Mind - WearRecyclerView and More
Let us Help Capture What is on Your Mind - Saving Data and Customizing the UI
Measuring Your Wellness and Syncing Collected Sensor Data
Let us Chat in a Smart Way - Notifications and More


Android Wear 2.0 is a powerful platform for wearable smart devices. Wear 2.0 enabled close to 72 percent new device activation in the wearable device market from the day Wear was announced. Google is working with multiple iconic brands to bring the best user experience to smart watches. Continuous improvement in the Wear hardware for new devices in the market shows the potential Wear devices can offer. Google introduced a whole new way of experiencing wearable technology with material design, standalone applications, watch face innovations, and more.

The Wear platform is becoming more popular, and Android developers can reap the benefits of improving their ability to program for Wear devices.

This book helps to create five Wear applications, with comprehensive explanations. We start with making a wearable note taking application by exploring Wear-specific user interface components and building a Wear map application with the ability to persist a quick note on the map. We will build a complete chat application with a companion mobile application. We will also build a health and fitness application to monitor pulse rate, a reminder to drink water, and so on, and also write a digital watch. We will complete the book by exploring the capabilities of the Wear 2.0 platform.

Have fun building great wear applications.

What this book covers

Chapter 1, Getting You Ready to Fly - Setting Up Your Development Environment, teaches you to write your first Wear application, explores the essential UI components specific to Wear applications, and discusses Android Wear design principles.

Chapter 2, Let us Help Capture What is on Your Mind - WearRecyclerView and More, covers WearableRecyclerView and the WearableRecyclerView adapter, and SharedPreferences, BoxInsetLayout, and the animated DelayedConfirmation.

Chapter 3, Let us Help Capture What is on Your Mind - Saving Data and Customizing the UI, explores the integration of the Realm database and custom fonts, UI updates, and finalizing the project.

Chapter 4, Measure Your Wellness - Sensors, showcases the accuracy of the sensors, battery consumption, Wear 2.0 doze mode, material design, and so on.

Chapter 5, Measure Your Wellness - Syncing Collected Sensor Data, focuses on syncing collected sensor data, collecting sensor data from a Wear device, processing the received data to find calories and distance, sending data to a Wear application from a mobile application, Realm DB integration, WearableRecyclerView, and CardView.

Chapter 6, Ways to Get Around Anywhere - WearMap and GoogleAPIclient, explains the Developer API console; the Maps API Key; and SHA1 Fingerprint, SQlite integration, Google Maps, the Google API Client, and Geocoder.

Chapter 7, Ways to Get Around Anywhere - UI controls and More, looks at understanding UI controls, marker controls, map zoom controls, StreetView in Wear, and best practices.

Chapter 8, Let us Chat in a Smart Way - Messaging API and More, discusses configuring Firebase for your mobile application, creating a user interface, understanding the messaging API, working with Google API Client, and building a Wear module.

Chapter 9, Let us Chat in a Smart Way - Notifications and More, covers Firebase functions, notifications, material design Wear app Wear 2.0 input method framework, and so on.

Chapter 10, Just a Face for Your Time - WatchFace and Services, outlines CanvasWatchFaceService and registering a watch face, CanvasWatchFaceService.Engine and callbacks, watch face elements and initializing them writing the watch face, and handling gestures and tap events.

Chapter 11, More About Wear 2.0, explores a standalone application, curved layout and more UI components the Complications API, different navigations and actions, wrist gestures, input method framework, and distributing Wear apps to the Play Store.

What you need for this book

To be able to follow with this book, you need a computer with the latest Android Studio version installed. You need internet to set up all the required SDK for Wear development. If you have a Wear device to test the application, that would be good; otherwise, Android Wear emulators will do the magic.

Who this book is for

This book is for Android developers who already have a strong understanding of programming and developing apps in Android. This book helps the reader advance from being an intermediate-level to an expert-level Android developer, by adding Wear development skills to their knowledge.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Specific commands or tools from the interface will be identified as follows:

Select the Save button.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

compile '' compile '' provided ''

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<?xml version="1.0" encoding="utf-8"?> < xmlns:android=""  xmlns:app=""  xmlns:tools=""  android:id="@+id/container"  android:layout_width="match_parent"  android:layout_height="match_parent"  tools:context="com.ashok.packt.wear_note_1.MainActivity"  tools:deviceIds="wear"> </>

Any command-line input or output is written as follows:

adb connect

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Let the default selected template be the Wear application code stub Always On Wear Activity."


Warnings or important notes appear like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you. You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at We also have other code bundles from our rich catalog of books and videos available at Check them out!


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title. To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at [email protected] with a link to the suspected pirated material. We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.