Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Android Wearable Programming
Android Wearable Programming

Android Wearable Programming: Expand on your Android development capabilities by building applications for Android Wear

eBook
€8.99 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Android Wearable Programming

Chapter 2. Creating Notifications

This chapter provides you with a background of essential features of Android notifications and how we can use these to send messages between a handheld device and a wearable device.

We will be taking a look at how we can use different notification methods to develop an application that shows how we can create basic and custom notifications. You will also learn how you can incorporate and make use of Android's voice capabilities to respond to notification messages that are contained within a notification.

At the end of the chapter, we will take a look at how we can use notification stacking to display multiple notification messages within a notification.

This chapter includes the following topics:

  • Introducing Android notifications
  • Creating a basic notification for wearables
  • Creating a custom notification for wearables
  • Receiving voice input within a notification
  • Receiving multiple notifications through a process called page stacking

Introducing Android notifications

Android notification is basically a way of communicating with the user. This is done by letting the user know of an upcoming appointment or of an incoming call or SMS message. The user can then decide how to respond to the option presented to him/her.

Notifications in wear are the result of events that happen on the paired smartphone, which are then mirrored on the wearable device, or contextual events like location-aware events or time, and date-based reminders. Android notification messaging works by communicating between the handheld device and wearable device over Bluetooth. When the connection has been established, the Google Play Service notification messages can be exchanged between the handheld device and the wearable. An example of a notification message that has been sent from the Android handheld device to the Android wearable can be seen in the following screenshot:

Introducing Android notifications

In the next sections, we will be taking a look at the different ways we can send...

Creating a basic notification for wearables

In this section, we will take a look at how to create a basic notification that will be displayed on our wearable device. So let's get started!

Firstly, create a new project in Android Studio by following these simple steps:

  1. Launch Android Studio, and then navigate to the File | New Project menu option.
  2. Next, enter WearNotifications for the Application name field.
  3. Then, provide the name for the Company Domain field.
  4. Next, choose Project location where you would like to save your application code:
    Creating a basic notification for wearables
  5. Finally, click on the Next button to proceed to the next step.

Specifying the form factors

Next, we will need to specify the form factors that our application will use, as will be using a single module instead of the app and wear modules as discussed previously in Chapter 1, Understanding Android Wearables and Building Your First Android Wear App.

On the following screen we will need to choose the minimum SDK version for our phone/tablet and perform the following...

Creating a custom notification for wearables

In this section, we will take a look at how we can create a custom notification message that will be entered by the user within our code example. This will be done on the paired smartwatch, with the notification being displayed on the Android wearable device.

So let's get started:

  1. First, open the activity_main.xml file, which is located in the res | layout folder structure within Project Navigator, and add the highlighted entries as shown in the following code snippet:
    <RelativeLayout    
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"  
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android...

Receiving voice input within a notification

In this section, we will be taking a look at how we can use notifications that can allow the user to respond to these by simply using their voice. Since Android wearable devices don't contain a keyboard, a user can swipe on a notification and respond to the action using their voice, or simply by choosing from a list of options presented to them, and tapping on the item right from their Android wearable device.

To receive voice input within a notification, perform the following steps:

  1. Open the MainActivity.java file from within the Project Navigator window.
  2. Modify the onCreate(Bundle savedInstanceState) method and add the following highlighted code:
    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            // Clear all previous notifications and
            // generate new unique ids
            NotificationManagerCompat.from(this).cancelAll(...

Receiving multiple notifications through a process called page stacking

In the previous sections, we have looked at how we can use notifications to send basic and customized notifications to our Android wearable device. In the final section, we will look at how we can use our notification service to group notifications through a process called page stacking.

This process helps us to intelligently collate and bundle similar items within a single collection to provide us with easy navigation from the same app. So, let's get started:

  1. Open the MainActivity.java file from within our Project Navigator window.
  2. Modify the onCreate(Bundle savedInstanceState) method and add the following highlighted code:
    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            // Clear all previous notifications and
            // generate new unique ids
            NotificationManagerCompat.from(this).cancelAll...

Introducing Android notifications


Android notification is basically a way of communicating with the user. This is done by letting the user know of an upcoming appointment or of an incoming call or SMS message. The user can then decide how to respond to the option presented to him/her.

Notifications in wear are the result of events that happen on the paired smartphone, which are then mirrored on the wearable device, or contextual events like location-aware events or time, and date-based reminders. Android notification messaging works by communicating between the handheld device and wearable device over Bluetooth. When the connection has been established, the Google Play Service notification messages can be exchanged between the handheld device and the wearable. An example of a notification message that has been sent from the Android handheld device to the Android wearable can be seen in the following screenshot:

In the next sections, we will be taking a look at the different ways we can send...

Left arrow icon Right arrow icon

Description

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.

What you will learn

  • Get introduced to the Android Wear and Google Glass SDK
  • Create your own basic and custom notifications for Android Wear by using Android notifications
  • Develop custom Android wearable watch faces and debug them over Bluetooth prior to packaging
  • Deploy your application to the handheld device or the Google Play Store
  • Develop apps that have the ability to send and receive binary blobs of data from the handheld device to the wearable device
  • Create custom layouts for the Android TV platform conforming to the Android TV design principles
  • Build effective user interfaces for the Google Glass platform
  • Incorporate voice and input features into your Android wearable app

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 30, 2015
Length: 224 pages
Edition : 1st
Language : English
ISBN-13 : 9781785281297
Vendor :
Google
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jul 30, 2015
Length: 224 pages
Edition : 1st
Language : English
ISBN-13 : 9781785281297
Vendor :
Google
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 103.97
Arduino Wearable Projects
€36.99
Android Wearable Programming
€24.99
OpenCV By Example
€41.99
Total 103.97 Stars icon
Banner background image

Table of Contents

7 Chapters
1. Understanding Android Wearables and Building Your First Android Wear App Chevron down icon Chevron up icon
2. Creating Notifications Chevron down icon Chevron up icon
3. Creating, Debugging, and Packaging Wearable Apps Chevron down icon Chevron up icon
4. Sending and Syncing Data Chevron down icon Chevron up icon
5. Working with Google Glass Chevron down icon Chevron up icon
6. Designing and Customizing Interfaces for Android TV Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(2 Ratings)
5 star 0%
4 star 100%
3 star 0%
2 star 0%
1 star 0%
T.M. Aug 23, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
This book is densely written and presents numerous screenshots and code listings. The kinds of devices covered are watches under Android Wear, Google Glass and Android TV. Two sample applications with the Wear SDK show how to send notifications and synchronize your data between the phone and the watch. The Google Glass sample covers voice recognition, controlling the camera and displaying current location on Google Maps. Finally, there’s a demonstration of a movie selector for Android TV.You don’t have to own this devices to test the apps as emulators are available.
Amazon Verified review Amazon
Amazon Customer Sep 12, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Steven F. Daniel takes a right-out-of-the-gate approach and is very hands-on in teaching the reader how to assemble effective, powerful wearable applications, primarily for Android Wear. I found the examples to be very pragmatic and worthwhile, exploring the major APIs - the Data API, Node API, and Message API - for the Android Wear platform and how to move data between a wearable device and an associated smartwatch.It also covers working with binary data and some of the unique gains you can get by using images in your wearable app. Additional topics that get good treatment are working with Android notifications across multiple platforms. It also covers debugging of wearable apps over Bluetooth, and proper UI/UX guidelines for ensuring that the main areas of “keeping technology out of the way” remain the primary goal for your wrist-bound products.I wrote a book on Google Glass development, so I was pleased to see the chapter on Glass Development Kit development, as well as working with Android TV, to show how a simple application can have relevance and presence across multiple Android platforms and devices.It’s a great quick read that gets you started on the exciting world of wearable development!
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.