Android Wearable Programming - Steven F. Daniel - E-Book

Android Wearable Programming E-Book

Steven F. Daniel

0,0
23,99 €

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

Mehr erfahren.
Beschreibung

If you are an Android developer who wants to learn how to build applications for the Android Wear platform, then this is the book for you. This book only requires a basic knowledge of Android programming. Familiarity with development IDEs such as Android Studio, IntelliJ IDEA, or Eclipse will be helpful.

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

EPUB
MOBI

Seitenzahl: 179

Veröffentlichungsjahr: 2015

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

Android Wearable Programming
Credits
About the Authors
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
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
Errata
Piracy
Questions
1. Understanding Android Wearables and Building Your First Android Wear App
Introducing Android wearables
Understanding the Android Wear architecture
Setting up an Android development environment
Installing the Android Wear support library
Setting up and configuring the Android (AVD) Emulator
Building a simple Android wearable application
Creating the mobile activity component
Creating the Android Wear activity component
Summary
2. Creating Notifications
Introducing Android notifications
Creating a basic notification for wearables
Specifying the form factors
Adding and customizing a blank activity
Adding dependencies to Gradle scripts
Creating a custom notification for wearables
Receiving voice input within a notification
Receiving multiple notifications through a process called page stacking
Summary
3. Creating, Debugging, and Packaging Wearable Apps
Creating an Android wearable watch face app
Presenting information inside the WatchFace class
Creating a custom watch face service class
Debug your Android wearable app over Bluetooth
Running apps directly on an Android Wear device
The Android wearable user interface guidelines
Packaging your Android wearable application
Summary
4. Sending and Syncing Data
Creating a wearable send and receive application
Creating a UI for the mobile activity
Creating a UI for the wear activity
Establishing connections for the mobile activity
Sending messages to the Android wearable
Receiving messages using MessageAPI
Transferring image data to the Android wearable
Receiving image data using DataApi
Summary
5. Working with Google Glass
Installing the Glass Development Kit preview
Installing the Google USB drivers for Windows
Creating and building a Google Glass application
Setting the theme for the Google Glass app
Configuring the project to run on Google Glass
Creating the custom menu resource file
Configuring the AndroidManifests file
Creating the custom camera layout resource file
Incorporating a voice input within Google Glass
Accessing camera through Google Glass
Incorporating the Google Maps API with Google Glass
Modifying the Google Glass main activity UI
Launching the app within Google Glass
An introduction to GDK and the Google Mirror API
The Mirror API playground
The Google Glassware principle design guidelines
Summary
6. Designing and Customizing Interfaces for Android TV
Creating and building an Android TV application
Customizing the Android TV user interface
Creating the CustomHeadersFragment class
Creating the CustomRowsFragment class
Creating the CustomFrameLayout class
Creating the SearchActivity class
Creating the SearchFragment class
Creating the custom activity layout resource file
The Android TV user interface design guidelines
Summary
Index

Android Wearable Programming

Android Wearable Programming

Copyright © 2015 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 author, 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: July 2015

Production reference: 1270715

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78528-015-3

www.packtpub.com

Cover image by Evelyn Lam (<[email protected]>)

Credits

Author

Steven F. Daniel

Reviewers

Marcus Gabilheri

Andreas Göransson

Dr. Jibo He

Qian He

Jason Salas

Commissioning Editor

Priya Singh

Acquisition Editor

Vivek Anantharaman

Content Development Editor

Amey Varangaonkar

Technical Editors

Utkarsha S. Kadam

Shiny Poojary

Copy Editor

Kausambhi Majumdar

Project Coordinator

Bijal Patel

Proofreader

Safis Editing

Indexer

Tejal Soni

Graphics

Jason Monteiro

Production Coordinator

Aparna Bhagat

Cover Work

Aparna Bhagat

About the Authors

Steven F. Daniel is the owner and founder of GENIESOFT STUDIOS (http://www.geniesoftstudios.com/), a software development company based in Melbourne, Victoria, that focuses primarily on developing games and business applications for the iOS, Android, Mac OS X and Windows platforms. He is an experienced software developer with more than 14 years of experience in developing desktop and web-based applications for a number of companies, including: ANZ, Department of Justice, BP Australia, and AXA Australia.

Steven is always interested in emerging technologies and is a member of the SQL Server Special Interest Group (SQLSIG), Melbourne CocoaHeads, and Java Community.

He was the cofounder and Chief Technology Officer (CTO) of SoftMpire Pty Ltd., a company that focused primarily on developing business applications for the iOS and Android platforms.

Steven is the author of various book titles, such as Xcode 4 iOS Development Beginner's Guide, iOS 5 Essentials, iPad Enterprise Application Development Blueprints, and Xcode 4 Cookbook, all by Packt Publishing. You can check out his blog at http://www.geniesoftstudios.com/blog/ or follow him on Twitter at http://twitter.com/GenieSoftStudio.

Acknowledgments

No book is the product of just the author — he just happens to be the one with his name on the cover. A number of people contributed to the success of this book and it would take more space than I have to thank each one individually.

I would personally like to thank two special people who have been an inspiration and who have provided me with so much support during the writing of this book: Vivek Anantharaman, my acquisition editor, who is the reason that this book exists, for being a wonderful guide throughout this whole process, and Amey Varangaonkar for his understanding and support, as well as his brilliant suggestive approaches during the chapter rewrites. Thank you for everything, guys.

Lastly, to my reviewers: thank you so much for your valuable suggestions and improvements, making this book what it is today. I am extremely grateful to each and every one of you.

Also, thanks to the entire Packt Publishing team for working so diligently to help bring out a high-quality product. Finally, a big thank you to the engineers at Google for creating the Android platform and providing developers with the tools to create fun and sophisticated applications.

Finally, I'd like to thank all of my friends for their support, understanding, and encouragement during the writing process. It is a privilege to know each and every one of you.

About the Reviewers

Marcus Gabilheri is a computer science student at Oklahoma State University. He was born in Brazil but lived in Spain for 11 years. He moved to the United States to be with his wife, Carissa Gabilheri, and decided to go back to school in the U.S. to follow his passion for programming. As a student at OSU, he has won the University's Mobile App Competition 2 years in a row. Marcus actively participates in the developer community as a Google Developer Group organizer and advocates Android development as well other technologies. He works as a mobile and web developer for Oklahoma State University and enjoys developing Android apps in his spare time. His latest achievement was in the Google Fit developer's challenge, where he was one of the 12 grand-prize winners of the challenge with his fitness app, FitHub.

I would like to thank my wife, Carissa Gabilheri, for understanding and putting up with all the late nights and uncountable hours that I spend in front of my computer. I would also like to say special thanks to my mother, Adriana Andreo, and my grandmother, Maria Antonia Andreo, for raising me by themselves and to my parents-in-law, Randy and Donna Wilson, for accepting me into their family when I moved from Brazil to the U.S.

Andreas Göransson has been programming mobile phones since before smartphones became popular. He has previously written two books on Android development and has been involved in several open source projects. Beyond his interest in working on the family farm, he is very interested in emerging technologies, specifically, Internet of Things, wearable devices, and cloud-based services.

Dr. Jibo He is currently an assistant professor at Wichita State University. He graduated from Peking University in 2007 and the University of Illinois in 2012 with a research specialty in engineering psychology. He won the Star of Tomorrow Award from Microsoft and was voted the Most Valuable Graduate by the University of Illinois. He directs the Human Automation Interaction Lab at Wichita State University. His lab does research on user experience, mobile devices, driving safety, aviation psychology, and human computer interaction. The goal of his research is to understand the human cognitive processes and develop technologies to improve performance, increase user experience, and mitigate human error. He has experience in developing for Google Glass, Android, iPhone, and smartwatches.

Qian He is an enthusiastic digital gadget lover and experienced software engineer. He got his bachelor's degree in software engineering from Beijing Institute of Technology. After working at IBM and studying at University of Chinese Academy of Sciences, he decided to pursue a doctorate degree in the United States. Currently, he is studying computer science at Worcester Polytechnic Institute. His main research fields are ubiquitous computing and mobile health. Over the last few years, Qian has been interested in wearable devices and has built several famous fitness apps for Android / Android Wear / Pebble.

Jason Salas is a product manager, developer, sportscaster, author, and filmmaker who enjoys a perpetual summer on the island of Guam.

He runs the R&D group for Guam's largest media company, where he also co-anchors the nightly news.

Jason coauthored Designing and Developing for Google Glass (http://www.amazon.com/dp/1491946458/ref=cm_sw_su_dp), by O'Reilly Media, published an e-book about the trials and tribulations of a season in a semipro football league, and previously contributed to a book on Microsoft Hailstorm. He's also a member of the Football Writers Association of America.

You can find Jason at https://plus.google.com/+JasonSalas/posts.

www.PacktPub.com

Support files, eBooks, discount offers, and more

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://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

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

Free access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

To my favorite uncle, Benjamin Jacob Daniel, for always making me smile and inspiring me to work hard and achieve my dreams, I miss you a lot.

Chan Ban Guan, for the continued patience, encouragement, and support, and most of all for believing in me during the writing of this book.

To my family, for their love and support, and always believing in me throughout the writing of this book.

This book would not have been possible without everyone's love and understanding and I would like to thank you all from the bottom of my heart.

Preface

Android Wear is becoming extremely popular, and offers a great opportunity for developers to learn how to build applications for the Android Wear platform, which is a special version of the core Android OS, and has been tailored for wearable computing devices such as smartwatches. These wearable devices come with a brand new user interface, which is the result of Google working with their customers to understand how they use their phones today and how they can be more in touch with their environment.

Android Wearable Programming provides a practical approach to developing and building Android apps using the Android Studio Integrated Development Environment. The new Android Studio IDE has introduced a specialized development environment that has been welcomed by the emerging Android community. This IDE is perfect to develop Android Wear apps because of the tight integration it has with the Wear development APIs, and also the streamlined build cycle with Gradle that helps to minimize a lot of manual configuration that the developer would need to do in other IDEs.

In this book, I have tried my best to keep the code simple and easy to understand by providing a step-by-step approach, with lots of screenshots at each step to make it easier to follow. You will soon be mastering the different aspects of Android Wear programming, as well as the technology and skills needed to create your own applications for the Android Wear platform.

Feel free to contact me at <[email protected]> if you have any queries, or if you just want to drop by and say "Hello".

What this book covers

Chapter 1, Understanding Android Wearables and Building Your First Android Wear App, describes the background of the Android Wear platform architecture and shows you how to set up and configure the Android development environment, before finally looking at how to create a simple Android Wear app.

Chapter 2, Creating Notifications, introduces you to Android notifications, where you will learn how to create basic and custom notification messages. You will learn how to incorporate voice capabilities to read out the content of the notification, before learning how to group multiple notification messages using page-stacking.

Chapter 3, Creating, Debugging, and Packaging Wearable Apps, focuses on designing and creating custom watch faces to present information within the Android wearable watch area. You will learn how to effectively debug your app over Bluetooth, before finally learning how to package your wearable app so that it can be used within the handheld mobile device.

Chapter 4, Sending and Syncing Data, introduces you to the Data Layer API and the Message API frameworks, so that you can synchronize image data from the handheld device with the wearable, as well as use the Message API to communicate between the handheld and the wearable to send and receive messages.

Chapter 5, Working with Google Glass, explores how to build effective user interfaces for the Google Glass platform by creating user interfaces that display content that responds to voice input commands, before finally learning how we can access the Glass camera to take a snapshot and save the image to local storage.

Chapter 6, Designing and Customizing Interfaces for Android TV, provides you with the background and understanding of how to effectively present your app within the main user interface and how you can design your app by following the Android TV UI Patterns to help users get the content they want quickly. Also, you will learn how to create and use fragments that allow information to be presented within the Android TV interface to represent your content.

What you need for this book

For this book, you need a computer running a Windows, Mac OS, or Linux system. You will also need to have the Android Studio IDE and both Java and Java Runtime Environment installed on your system.

Who this book is for

This book is intended for developers who have a working experience of the application development principles for the Android platform and wish to expand their Android capabilities by developing applications for Android wearables using the key features of Android Studio. It's assumed that you are familiar with object-oriented programming and the Java programming language.

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 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 from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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.

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. Understanding Android Wearables and Building Your First Android Wear App

When Google announced Android Wear at their Google I/O conference back in March 2014, developers were excited and started embracing this technology to see what types of applications they could create to communicate between the Android handheld device and Android wearable, while making our day-to-day lives a lot easier.

Android wearables bring a personal touch by allowing consumers to interact with their devices on a different level, and are aimed at reducing people's interaction with their mobile phones. This could include receiving a simple notification message reminding you to pick up something on your way home from work, or that you have an upcoming appointment. There is even an ability to receive messages from your favorite social networking application, for example, Facebook.

This chapter provides you with a theoretical background of Android, and how to develop applications for the Android Wear platform from Google. This platform allows your Android wearable device to communicate with your phone wirelessly over Bluetooth, and many manufactures like Samsung and LG have embraced this technology and created wearable devices, such as the Samsung Gear Live and the LG G Watch R smartwatches.

In later chapters, we will be working with some of these APIs and seeing how we can incorporate these in our applications to communicate between our Android phone and Android Wear devices.

This chapter includes the following topics:

Introducing Android wearablesUnderstanding the Android Wear architectureBuilding a simple Android wearable application