ebook img

Beginning Android Wearables PDF

495 Pages·2015·6.8 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Beginning Android Wearables

Companion BOOKS FOR PROFESSIONALS BY PROFESSIONALS® eBook F A o n u Available d n R roid in el d ea 5. Although wearable devices have existed since the 70s, they have only recently become se 0 mainstream. Google Glass and Android Wear smartwatches, in particular, are rela- tively new devices that provide countless opportunities for creating innovative apps with unprecedented user experiences. Beginning Android Wearables gives you the skills you need to take part in the wearable revolution and to delight your users by providing the information they need at the tips of their fingers. This book is very practical and contains many examples that show you not only how to write code for Glass and Android Wear, but also how to apply this code in the context of an app. • Build notifications for handheld apps that are automatically shared with B Glass or Android Wear, and learn to customize these notifications specifically e g for wearables • Create apps that run directly on Android Wear devices and leverage the in Android Wear SDK n • Use the wearable UI library to build effective user interfaces for Android Wear in • Use the wearable data layer API to share and synchronize data between a g handheld device and Android Wear • Build custom watch faces for Android Wear A • Build Glassware (that is, apps for Glass) using the Glass Development Kit (GDK) n • Use the views and widgets of the GDK to build effective user interfaces for Glass • Receive user input on Glass with touchpad gestures, head gestures, d and voice recognition r • Take pictures and record videos on Glass by either leveraging the native camera o app or with the Camera API • Utilize location providers and orientation sensors to build contextually i d sensitive apps • Learn methodologies for building apps, including generative research, user W interviews, and prototyping e a r a Beginning b l e s Android Wearables Andres Calvo C a l v o COMPANION eBOOK ISBN 978-1-4842-0518-1 US $ 44.99 54499 Shelve in Mobile Computing SOURCE CODE ONLINE User level: www.apress.com Beginning–Intermediate 9781484205181 For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance About the Author ����������������������������������������������������������������������������������������������������xix About the Technical Reviewer ��������������������������������������������������������������������������������xxi Acknowledgments ������������������������������������������������������������������������������������������������xxiii ■ Part I: Introduction �����������������������������������������������������������������������������1 ■ Chapter 1: Introducing Android Wearables �����������������������������������������������������������3 ■ Part II: Notifications��������������������������������������������������������������������������17 ■ Chapter 2: Reviewing Notifications for Android ��������������������������������������������������19 ■ Chapter 3: Customizing Notifications for Wearables �������������������������������������������55 ■ Part III: Android Wear �����������������������������������������������������������������������93 ■ Chapter 4: Running Apps Directly on Android Wear ��������������������������������������������95 ■ Chapter 5: Android Wear User Interface Essentials ������������������������������������������129 ■ Chapter 6: The Wearable Data Layer API �����������������������������������������������������������173 ■ Chapter 7: Creating Custom Watch Faces ���������������������������������������������������������215 v vi Contents at a Glance ■ Part IV: Google Glass ����������������������������������������������������������������������273 ■ Chapter 8: Running Apps Directly on Glass �������������������������������������������������������275 ■ Chapter 9: Glass User Interface Essentials ��������������������������������������������������������295 ■ Chapter 10: Gesture and Voice Recognition ������������������������������������������������������349 ■ Chapter 11: The Camera: Taking Pictures and Recording Video �����������������������381 ■ Part V: Android Wear and Glass �����������������������������������������������������417 ■ Chapter 12: Location and Orientation ����������������������������������������������������������������419 Index ���������������������������������������������������������������������������������������������������������������������477 I Part Introduction 1 1 Chapter Introducing Android Wearables We already know that mobile devices have been expanding at such a fast pace that they’re practically ubiquitous: we can check our email, send and receive chat messages, or even start video conferences regardless of whether we’re at home or on the road. Mobile devices, however, have their limitations: they require your dedicated attention and they occupy at least one hand. Wearables devices address these limitations and have the potential of revolutionizing the way we interact with technology. When building apps for wearables, do not forget that wearable devices are not meant to replace mobile devices, but rather to complement them. To provide the best possible user experience for a given application, build it for the most suitable platform. While complex interactions such as browsing the internet are best suited for mobile devices, wearables excel at quickly displaying glanceable information such as a runner’s current time and distance. In addition to providing a better user experience under certain circumstances, wearables also contain sensors that open new possibilities for contextual awareness. For instance, many wearables contain a heart rate sensor, which can help evaluate the quality of a user’s workout and offer suggestions. In this chapter, we’ll elaborate on the benefits of wearables, including their potential for increased contextual awareness and unprecedented user experiences. Then, we’ll introduce Android Wear and Google Glass, and we’ll talk about their basic user interfaces. Wearables and Contextual Awareness People typically place mobile devices in their pockets, purses, or backpacks, whereas by definition wearable devices are always placed on the body. In particular, users wear Glass on their faces and Android Wear devices on their wrists. In a way, wearable devices are more personal than mobiles. 3 4 CHAPTER 1: Introducing Android Wearables By being closer to you, wearable devices are able to learn more about where you are and what you’re doing. For instance, while a mobile device knows what direction it’s facing, Glass knows what direction you are facing. Android Wear devices can also measure or infer context beyond the reach of mobile devices. Consider, for example, the BioGlass project from MIT Media Lab’s Affective Computing group. BioGlass leverages the accelerometer and gyroscopic sensors of Glass to derive a user’s heart rate and respiration rate with an accuracy comparable to the values obtained by traditional vital sensors. Heart beats and respiration elicit subtle movements throughout a user’s body, and Glass can detect these movements and use them to infer a user’s vitals. This procedure is only possible because Glass is in close contact with a user’s body. For more information, see the BioGlass homepage (http://bioglass.media.mit.edu/). The LynxFit Glassware, which is available from the MyGlass store, also demonstrates how wearables can achieve contextual awareness that would not be possible with mobile devices. This Glassware guides users through workouts and tracks their progress. During a workout, it utilizes the sensors of Glass to count exercises as users perform them. Being able to detect exercises in real time and concurrently show users feedback is only possible because of the unique form factor of Glass. A third example is an alarm app I wrote for Android Wear that makes sure users wake up by checking the watch’s sensors to ensure they are standing. If users dismiss the alarm and fall asleep, the app detects a short period of inactivity and restarts the alarm. This app can reliably detect periods of inactivity because of its direct contact with a user’s wrist. Wearables and User Experience A common misconception is that wearables are intended to replace mobile devices. In reality, wearables complement mobile devices and may even be dependent on them. For instance, Android Wear watches cannot access the internet or download any apps without being paired to a mobile device. The objective of designers and developers should be to maximize the user experience and to quickly present the right information with minimal user intervention. Certain applications are better suited for wearables than mobiles and vice versa. Starting a timer, for instance, is a faster and cleaner process on Glass than on a mobile. On the other hand, crafting a lengthy reply to an email is manageable on a mobile but tedious on Glass. While there is no exact formula for determining what applications are better suited for wearables, in general, wearables are most effective for simple and short interactions. Additionally, wearables are useful in situations where users cannot easily access mobile devices. For example, consider a Glassware that tracks runs and bicycle rides called Strava, which is available from the MyGlass store. Strava utilizes GPS to measure a user’s key stats, such as distance and pace. To view these stats during a run or a ride, users must simply look up to see them on Glass. In contrast, viewing these stats on a mobile phone would be distracting and tedious since users would have to take out their phones during the activity. Holding a phone while riding a bicycle is particularly disruptive since users should have both hands on the handlebars. CHAPTER 1: Introducing Android Wearables 5 Why Android Wearables? Although this book focuses on Android-based wearables (namely Glass and Android Wear), wearable computers have existed for decades before the introduction of Android. In 1961, for instance, Edward Thorp and Claude Shannon built a wearable computer to help increase the odds of winning at roulette. The user would use switches inside his shoe to initialize the computer and time the rotor and the ball. The computer would then calculate the octant on which to bet and transmit the result to a collaborator’s earbud through a radio. The collaborator would make the bets to reduce suspicion, since he would be located in a seat with a poor view of the ball and rotor. For more information, see the article “The Invention of the First Wearable Computer” by Thorp (https://www.cs.virginia.edu/~evans/thorp.pdf). Not only did wearable computers exist before Android wearables, but there are also other emerging wearable computers such as the Meta (https://www.spaceglasses.com/). Why should we learn to build applications for Android wearables instead of other devices? Here are a few reasons:  Android has matured into a powerful platform that we can leverage while building apps for Android wearables.  Google is working on the next versions of Glass and Android Wear, so the platforms will only get better with time.  Glass and Android Wear are relatively new platforms, and the best apps and user experiences are yet to be developed. Android contains tens of thousands of APIs and has been extensively tested on handhelds. Glass and Android Wear leverage most of these capabilities and provide features such as location, orientation, and Bluetooth right out of the box. These capabilities let you build sophisticated apps that would not otherwise be feasible on new platforms. What Can Android Wear Do? There are currently several Android Wear watches available in the market. The Samsung Gear Live and the LG G were the first devices to be released and have a square screens. In contrast, the Moto 360 and the LG G R, which were released shortly after, have round screens (see Figure 1-1). 6 CHAPTER 1: Introducing Android Wearables Figure 1-1. Android Wear devices can have square screens (left) or round screens (right) With regards to hardware, Android Wear devices usually have orientation sensors (that is, an accelerometer, gyroscope, and magnetometer), Bluetooth low energy, a vibrator, a touchscreen, and a microphone, but they vary in terms of other capabilities. Some Android Wear devices have an ambient light sensor, but not all of them. For instance, the Moto 360 has one but both the Samsung Gear Live and the LG G do not. Ambient light sensors are used to automatically adjust a device’s brightness depending on current lighting conditions. Certain watches such as the Samsung Gear Live and the Moto 360 include heart rate sensors, but the LG G does not. These optical sensors measure your heart rate, but are still a little slow and unreliable. Future Android Wear devices will likely improve this sensor and could even contain additional health sensors. Android Wear devices do typically not have WiFi, a camera, or speakers (although they can pair with bluetooth headphones). Note that Android Wear can still access the internet if paired to a mobile device. The Context Stream The interface of Android Wear is based on the context stream, which is a vertically scrolling list of cards similar to a ViewPager. In Android Wear, a card refers to a white card of content, as shown in Figure 1-2. Cards in Android Wear are typically displayed on top of a background image that provides additional context. CHAPTER 1: Introducing Android Wearables 7 Figure 1-2. A card in Android Wear contains content and is typically displayed on a background that provides additional contextual information Each card in the context stream can contain additional pages of related information. Users swipe vertically to navigate through the cards in the context stream and swipe horizontally to reveal a particular card’s additional pages. When users want to get rid of a card, they dismiss it by swiping from right to left. Apps can post their own cards to the context stream, which allows users to receive information without having to explicitly open apps. That being said, users can still open apps explicitly by using the cue card. The Cue Card Users open the cue card by saying “OK Google” or by tapping on the upper portion of the background of the home screen. The cue card lets users trigger actions by either 1) saying the name of the action out loud or 2) manually selecting the action from a list that can be accessed by swiping up (see the left of Figure 1-3).

Description:
Although wearable devices have existed since the 70s, they have only recently become mainstream. Google Glass and Android Wear smartwatches, in particular, are relatively new devices that provide countless opportunities for creating innovative apps with unprecedented user experiences. Beginning Andr
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.