Mastering Android Wear Application Development - Siddique Hameed - E-Book

Mastering Android Wear Application Development E-Book

Siddique Hameed

0,0
31,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

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.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 164

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Mastering Android Wear Application Development
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Introduction to Wearable Computing
Evolution
Moore's law
Ubiquitous computing
Mobile meets wearables
Hello Android Wear
Summary
2. Setting up the Development Environment
Android Studio
Installation
Git and GitHub
Gradle
Android SDK packages
Android Virtual Devices
Let's build a skeleton application
Summary
3. Developing Android Wear Applications
Skeleton app
The Android manifest file
Gradle build files
App activities
Let's build an Android Wear app
Summary
4. Developing Watch UI
Wearable UI
The Android manifest file
The TodayActivity activity
Actions inside the arrays.xml file
Main activity layout file
The WearableListItemLayout component
The DayOfYearActivity class
The activity_day_of_year.xml file
Summary
5. Synchronizing Data
What is a companion app anyway?
Setting up an Android Wear virtual device
Revisiting the Today app
Scope of the new Today app
The Wearable data layer API
MessageApi
WearableListenerService
DataListener
Cloud Node
The GoogleApiClient class
The Volley library
The JSoup library
The Build Script
Companion app's Android manifest file
The TodayMobileActivity class
Wearable app's Android manifest file
The OnThisDayActivity class
The HandheldListenerService class
Messages not coming through to your Wear app?
Summary
6. Contextual Notifications
Getting notified
Core classes of the notifications API
NotificationCompat.Builder
Action buttons in your notification
Wearable-only actions
Delivery
Today app with to-do notifications
Geofencing
Mocking a GPS
The build.gradle file on wear and mobile apps
Handheld app's Android manifest file
The TodoMobileActivity class
To-do list view
Adding to-do items
Mock locations
Mocking locations using FakeGPS app
The GeofenceTransitionIntentService class
Handheld app notification
Wearable app notifications
Summary
7. Voice Interactions, Sensors, and Tracking
Voice capabilities
System-provided voice actions
App-provided voice actions
New feature - adding to-do items through voice commands
Add to-do Item - a new action in the wearable app
The AddTodoItem activity in the wearable app
Handling speech inputs
Handheld app
Motion sensors
Gyroscope
Accelerometer
New feature - tracking our steps
Add to-do item - a new action in the wearable app
Summary
8. Creating Custom UI
Android Wear UI design
Common UI patterns
Cards
Countdowns and confirmations
Card stacks
2D Pickers
Selection lists
Revisiting the OnThisDay activity
The OnThisDayActivity activity
The activity layout
Summary
9. Material Design
Approaching material design
Interacting with the world
A visual language
To-do item menus
About the navigation drawer
The TodosActivity class
The TodoItemTypeFragment class
The NavigationAdapter class
Navigation item
The WearableDrawerLayout class
Menu items
Menu listener
Switching to-do types
Summary
10. Watch Faces
Telling the time
What is a watch face?
Design considerations
Implementation considerations
The watch face service
Interactive watch faces
Performance considerations
Let's build a watch face
The Android manifest file
The TodayWatchFace service
The TodayWatchFaceService class
The onTimeTick method
Drawing the watch face
Ambient mode
Customizing the watch face
The WatchFaceConfigActivity class
Summary
11. Advanced Features and Concepts
Keeping the watch running
Making an app to stay always on
An always running step counter
The Android manifest file
The StepCounterActivity class
Debugging wearable apps
Device setup
USB debugging on the handheld app
Bluetooth debugging on the wearable app
Session setup on the handhelds apps
The way forward - reviewing Android Wear 2.0
Watch face complications
Navigation and action drawers
Expanded and messaging style notifications
The Input Method Framework
Remote input and smart reply
Wrist gestures
Bridging mode
Standalone wearables
Summary
12. Publishing Apps to Google Play
Testing
The need for testing
Types of unit test
Automating user interface tests
Test APIs
JUnit
The AndroidJUnitRunner class
Espresso
View and Adapter matching
Action APIs
UI Automator
Monkey and monkeyrunner
The human touch
App distribution
Packaging
Publishing and opt-in
Summary

Mastering Android Wear Application Development

Mastering Android Wear Application Development

Copyright © 2016 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: December 2016

Production reference: 1021216

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham 

B3 2PB, UK.

ISBN 978-1-78588-172-5

www.packtpub.com

Credits

Authors

Siddique Hameed

Javeed Chida

Copy Editors

Pranjali Chury

Safis Editing

Reviewers

Mark Elston

Project Coordinator

Suzanne Coutinho

Commissioning Editor

Edward Gordon

Proofreader

Safis Editing

Acquisition Editor

Sonali Vernekar

Indexer

Tejal Daruwale Soni

Content Development Editor

Zeeyan Pinheiro

Graphics

Kirk D'Penha

Technical Editor

Pavan Ramchandani

Production Coordinator

Shraddha Falebhai

About the Authors

Siddique Hameed is a pragmatic technologist currently working on Simplify Commerce (https://simplify.com), a payment gateway platform from MasterCard. During his diverse career roles, he’s been crafting software for Fortune 500 companies to startups of industry domains ranging from finance, commerce, social media, telecom, bioinformatics, publishing, and insurance.

He is passionate about technology, software and their effects on day-to-day lives. He is a strong believer in open-source software culture and actively contributes to many open-source projects. On times, he speaks at technology events, meetups, and mentor contestants in hackathons. He likes teaching kids and adults in programming, technology and software development, and volunteers on coding initiatives such as Girls Who Code, Code.org, and STEM (science, technology, engineering, and mathematics) programs.

In his spare time, he likes traveling, goes on long road trips, tinkering with Raspberry Pi and building DIY gadgets.

Dedicated to my Mom, Dad, Wife, and two wonderful daughters!

Javeed Chida currently works as a senior software engineer for Apollo Education Group, a leader in global education. He has worked with several teams over the years developing multi-layered enterprise applications for companies spanning several industries including education, finance, medical, insurance, construction, and legal.

He is passionate about Java portals and particularly enthused by the Liferay portal platform. He also has a love for clever and innovative technical documentation. Apart from periodically churning out articles as a highlighted community blogger on Liferay.com. He spends his leisure absorbed in creative writing projects, particularly classical poetry and fiction.

About the Reviewer

Mark Elston is a software architect for an automated test equipment company working primarily in the IC and mobile device test world.  However, his 30 years of experience includes developing aircraft and missile simulations for the Air Force and Navy, hardware control systems for NASA, and tester operating systems for commercial products. He has also developed several Android applications for fun.  His latest passion is delving into the world of Functional Programming and Design.

I would like to thank my wife for her understanding when I had a chapter to finish reviewing. I would also like to thank Suzanne Coutinho for giving me the opportunity to work with her and the Packt team on this project. It has been enlightening and entertaining. Finally, I would like to thank the authors for taking even my smallest comments into account. It is a pleasure to be part of a project where your inputs are valued.

www.PacktPub.com

For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www.packtpub.com/mapt

Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

Preface

This book is intended for developers working on mobile, desktop, or web platforms interested in learning how to build apps for wearable devices, also known as wear apps. Furthermore, you may already have apps featured on the Google Play store and are looking to provide Android Wear support for your existing Android apps. If either of these statements is true, then yes, this book is for you.

Our primary goal in this book is to provide you, the reader, with a solid understanding of the philosophy, thought process, development details, and methodologies involved in building well-designed and robust Android Wear applications. We'll cover the advantages and the disadvantages of the wearable computing paradigm, and in doing so, we hope to provide a strong foundation for building wearable apps to meet practical and real-world use cases.

We will explore a wide range of concepts and features, from basic to medium to advanced, with varying degrees of complexity. Code samples accompanying each chapter are intended to give you hands-on knowledge of using the tools, libraries, SDKs, and other relevant technology needed to build Android Wear apps.

As you journey through the chapters of this book, you can expect to achieve the following objectives:

Understand wearable computing technologySet up your development environment for building Android Wear apps using Android StudioBegin a mastery of the Android Wear SDK and APIsUnderstand the commonly used UI patterns and UX principles surrounding Android Wear app developmentWork with different form factors of wearable devices (round, square)Take advantage of the sensors available on Android Wear devicesDevelop Android Wear sample apps to try out the concepts you learnCommunicate between Android mobile (handheld) and Android Wear appsLearn how to publish Android Wear apps to the Google Play store

What this book covers

Chapter 1, Introduction to Wearable Computing, covers the basics of wearable computing in general and how the technology has evolved. It also includes discussions on mobile computing, ubiquitous computing, and cloud computing.

Chapter 2, Setting up the Development Environment, shifts the focus on getting the readers familiar with setting up a development environment, from IDE installation to a discussion of the SDKs and libraries needed for Android Wear development.

Chapter 3, Developing an Android Wear App, walks the reader through step-by-step instructions for developing an Android Wear application, the Today app, from scratch using Android Studio.

Chapter 4, Developing Watch UIs, extends the Today app using UI components available in the Android Wear SDK and builds custom UI components using custom layouts.

Chapter 5, Synchronizing Data, introduces the idea of the need for a companion handheld app, including the steps to pair a handheld with an Android Wear emulator, thereby expanding your environment for wearable app development. The Today app is further extended to demonstrate these concepts.

Chapter 6, Contextual Notifications, discusses notifications in Android Wear and extends the Today app with an On This Day activity to demonstrate the Android Wear Notifications API.

Chapter 7, Voice Interactions, Sensors, and Tracking, discusses the voice capabilities offered by the Wear API. We define a voice action to launch our app. We introduce device sensors and discuss how they can be used to track data.

Chapter 8, Creating a Custom UI, covers the design principles that are central to the Android Wear UI space and examines a few common Wear UI patterns. We also augment the On This Day activity to display in a user-friendly format.

Chapter 9, Material Design, provides a conceptual understanding of material design and touches upon a few key principles specific to wearable app design and development. We solidify our understanding by extending our Todo app from the previous chapters to incorporate a navigation drawer that lets us switch between to-do categories, view items, and perform actions specific to each category.

Chapter 10, Watch Faces, introduces the concept of watch faces in this chapter. After a brief survey of the Android Wear APIs available to help us develop watch faces, we develop a simple interactive watch face.

Chapter 11, Advanced Features and Concepts, describes the design concerns and API features related to making apps run as if they were always on. We develop an activity to demonstrate the always-on capability provided by the Wear API. We also touch upon debugging wear apps over Bluetooth connections.

Chapter 12, Publishing Apps to Google Play, discusses the tooling available to test Android Wear apps and how to automate UI testing. We conclude the chapter with step-by-step instructions to get the app ready for publishing.

What you need for this book

You will require the following set of tools to try out the codes in the book and to practice the application development yourself:

Android Studio v2 or greaterJDK v7 or greaterGit version controlA development system with decent hardware configurations, such as a fast CPU and adequate RAM for developing mobile applications

Who this book is for

Java application developers—web, desktop, or mobile who wants to gain exposure to the Android Wear platform and equip themselves with the knowledge necessary to master the development of Android Wear apps.

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 to 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 www.packtpub.com/authors.

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 http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.Hover the mouse pointer on the SUPPORT tab at the top.Click on Code Downloads & Errata.Enter the name of the book in the Search box.Select the book for which you're looking to download the code files.Choose from the drop-down menu where you purchased this book from.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 WindowsZipeg / iZip / UnRarX for Mac7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Mastering-Android-Wear-Application-Development. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/MasteringAndroidWearApplicationDevelopment_ColorImages.pdf.

Errata

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 http://www.packtpub.com/submit-errata, 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 https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

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.

Questions

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.

Chapter 1.  Introduction to Wearable Computing

 

"The more you know about the past, the better prepared you are for the future."

  --Theodore Roosevelt

In this chapter, we will discuss the evolution of wearable computing and understand how it fits with other computing paradigms, such as desktop, mobile, and ubiquitous computing.

Evolution

Wearable computing, although widely believed to be the latest technological innovation, had existed even during the days of the abacus, a calculating tool that was used centuries ago by merchants and traders. According to a historical source on Chinese culture, it is believed that an abacus inlaid in a ring was used as a calculator during the Qing dynasty (http://www.chinaculture.org/classics/2010-04/20/content_383263_4.htm):