The market for smart wearable technology is forecast to grow by over 500% in 2015 compared with 2014, with vendors shipping over 25 million units. Bluetooth® Smart is integral to many of these devices, providing users with a seamless, “just works” connected experience. Wearable devices, smartphones and cloud-based Internet services can all work together with no explicit action or special knowledge required on the part of the user. Yes, it really is just like magic! In my series of blog posts on beacons for developers, I discussed smartphone applications which monitor for and react to the presence of Bluetooth® beacons. In part 2 of the series, I described a museum guide application for Android smartphones which used Bluetooth beacons to alert the user to the proximity of key museum exhibits. In this blog series, I now consider how the beacon experience can be made a wearable one and describe how I went about creating a museum guide for your wrist.
In 2014, Google announced Android Wear, a new version of the Android operating system designed for wearable devices. Android Wear allows bidirectional communication between wearable devices and other devices which are running the “full” Android operating system. Typically Android Wear devices like my Moto 360 smartwatch work in conjunction with an Android smartphone.
Architecture and the Role of Bluetooth Smart
In the world of Android Wear, devices are known as nodes, they each have particular capabilities and they’re connected in the Wear Network. Typically a smartphone will form the hub of the Wear Network with other types of nodes such as smartwatches connected to it. Node-to-node communication uses Bluetooth Smart. As an Android Wear developer, you need to know little or nothing about Bluetooth Smart however! The APIs for Android Wear have hidden the underlying Bluetooth® technical details, making it really easy to accomplish some very cool results. That said, Android Wear also allows you to use standard Android Bluetooth Smart APIs such as android.bluetooth.le.BluetoothLeScanner directly from your Android Wear application, so it is possible to interact with other Bluetooth Smart devices from a wearable, without any form of collaboration with a smart phone. Wearable devices are likely to be significantly less powerful than the smartphone hub so it’s more common for wearables and smartphones to work together, with the smartphone doing any heavy lifting which might be required. I’ll focus on these types of scenario in this article.
Three Approaches to the Wearable Museum Guide
I looked at three different ways in which I could extend my Museum Guide smartphone application to a Moto 360 smartwatch:
- Use standard Android notifications
- Use notifications extended for Android Wear devices
- Develop an Android Wear application which runs on the wearable
I’ll describe each of the two notification-based approaches in this article and look at developing an Android Wear application in Part 2.
So here’s some really good news. Any notification which an Android smartphone raises will automatically be delivered to each connected wearable. So if you already use notifications in your Android smartphone application, you can consider your application to be wearable-friendly without having written a single, specialised line of code. How cool is that?
Part 2 of my beacon series includes a snippet of code used to generate notifications.
Extended Notifications for Wearables
The Android APIs provide a means by which you can tailor notifications for wearable devices and do much more than just display notifications generated from your smartphone in an equivalent way on the wearable device. For example you can utilise special text styles, set the background image used in the notification, set up multiple pages that the user can swipe through for notification details and last but not least, you can add “actions” to your notification to make it interactive when viewed on the wearable device. I decided to provide users with multiple pages of information on their Android Wear device and also add some interactivity so that users could indicate whether they liked or disliked a particular exhibit. This was quite easy to accomplish, largely by leveraging a helper class called WearableExtender. Let’s briefly review the code. We begin by creating three pages containing the primary items of information about the exhibit. We use a text style designed for wearable devices to make information easier to read as well.
Next we create Action objects corresponding to the interactive Like and Dislike choices we want to offer to the user. Actions are similar to pages but have an associated Intent, wrapped in a PendingIntent object. In Android, an Intent is an operation to be performed and a PendingIntent is an Intent which can be handed to another application for execution. In this case, the other application is the smartphone Museum Guide application and I’m stipulating that the PendingIntent should launch an Activity called NotificationActionHandler.
Finally, we create a Wearable Extender which contains our additional pages and actions, and build a Notification which includes it, along with data representing generally applicable settings and our first notification page. We trigger the notification and that’s it. The wearable device receives a multi-page, interactive notification.
The resultant notification is depicted below using screen shots taken from my smartwatch.
When the Like or Dislike action is selected, the NotificationActionHandler Activity launches on the smartphone and displays one of the following screens:
As you can see, you can do a lot purely by exploiting Android notifications.
Getting started with Android Wear is easy. Notifications are already familiar to most Android developers and Bluetooth® Smart takes care of communication between smartphone and wearable device quietly, behind the scenes without the developer needing to have any special knowledge of the subject.
Martin is on the Bluetooth Developer Relations team. He specializes in mobile applications and technology, with over 30 years of experience in software development.