Book Image

Mastering Android Wear Application Development

By : Siddique Hameed, Javeed Chida
Book Image

Mastering Android Wear Application Development

By: Siddique Hameed, Javeed Chida

Overview of this book

Wearable technology is the future of mobile devices. It looks set to be a breakthrough technology, just like the iPad was before it. With the Apple Watch being widely regarded as a success, all eyes are now on Google to provide a similar device for its users. Keep your skills ahead of the competition and be one of the first to fully understand this powerful new trend. This book will give you a very solid understanding of the philosophy, thought process, development details, and methodologies involved in building well-designed, robust Android Wear applications. We cover the advantages and disadvantages of the wearable computing paradigm and provide a good foundational knowledge for you to build practical, real-world wearable apps. You will learn about the various tools, platforms, libraries, SDKs, and technology needed to build Android Wear apps. By the end of the book, you will be an expert in building Android wearable apps.
Table of Contents (18 chapters)
Mastering Android Wear Application Development
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface

An always running step counter


Now, let's demonstrate everything we presented in the previous section in practice by augmenting our step counter from Chapter 7, Voice Interactions, Sensors, and Tracking, to be always on. Let's dive right in.

The Android manifest file

The first thing to do is to update the AndroidManifest.xml file and set up the StepCounterActivity class to have its launchMode set to singleInstance. This is necessary in order to update the screen more than once per minute in ambient mode. Not doing so will cause the AlarmManager class to launch an intent to open a new activity every time the alarm is triggered rather than reusing the same (already active) activity. Here is the snippet from the file:

<activity 
    android:name=".StepCounterActivity" 
    android:label="@string/daily_step_count_title" 
    android:launchMode="singleInstance" 
/> 

As soon as we launch our step counter, we see a colorful background image and a display showing the number of steps taken so...