Your One-stop Guide to Developing an Android Wear App - Development Company

Your One-stop Guide to Developing an Android Wear App

The exciting new Android Wear is a technological marvel that lets you enjoy certain Android phone perks on your wrist.

Released last year, Android Wear as been getting quite the attention, from both consumers and aspiring devs. If you fall in the latter category and wish to understand how to have your application ready to exploit a new and innovative way of getting users to interact with contextual information, this article is for you.

When designing Android Wear, Google’s aim was to release information to users in the right quantity and at the right time. With that general theme in mind, Google has laid out design guidelines to get developers better-geared towards Wear application development. Bearing this in mind, we’re going to shed light on what’s required to start making apps on the Android Wear platform and what APIs are currently available to help you ready your app.

Understanding Usage Patterns

Users interact with an Android Wear device through “suggest” and “demand”.

The former refers to useful and timely information that’s ‘pushed’ to the user’s Wear device as a notification. The user interface thinks of this as a Card:

02

It should be noted that Wear apps are aware of context and push only information that is contextual and relevant. All such notifications need to be short, timely and easy to read. They require minimal input from the user.

Uses for “suggest” include flight schedule changes, instant messages, the weather, stock updates and so on.

When it comes to “demand”, users interact with their wearable through voice and it responds with precise information. A mic lets users invoke a list of standard actions by tapping the home screen or saying “OK, Google”. At this point the interface displays specific prompts to let users for example, call someone, send a message, or take a note.

You can get your app to either register these standard actions or come up with your own unique cue text.

03

Design Philosophy

Now that we have Android Wear usage patterns out of the way, we can observe the UI along with its design guidelines and principles.

Mostly all information is viewable by the user in a card form:

04

Take a close look at the different parts of this card. With hardly any modification required, your Android app notification would look more or less the same. However, since we’re talking about the least amount of information being displayed, that’s contextually relevant and also easy to read – careful consideration needs to be given to when you’re going to raise notifications and how much text needs to be displayed.

Notifications can be displayed as single or multiple cards. In case of multiple cards, users can swipe left to right to navigate between pages.

06

Multiple notifications can also be provided by stacking them together:

07

When designing apps for the Android Wear experience, four key aspects must be kept in mind:

  • Automatic app launch: Users should never have to reach out to launch apps on a Wear platform, since it’s not a phone. Wear apps should always be aware of the context, time, location and activity – the relevant card should be inserted accordingly.
  • Glance-friendly: Since the device is used from the user’s wrist, notifications should be as easy to read as it is to check the time on a regular watch. Keep that in mind, and pay close attention to the title, which should be kept to a minimum, easily read at a glance and completely relevant.
  • A good balancing act: This is what the Android Wear developer page says – “Android Wear is like a great personal assistant … it only interrupts you when absolutely necessary, and it’s always on hand to provide a ready answer.” You need to be able to offer this experience as a developer, so be thoughtful so as to when and how you’re going to use the Suggest and Demand models.
  • Almost nil interaction with the user: When developing apps, naturally, it must be kept in mind that they’re going to be viewed in a significantly smaller display. They need to be user-friendly at all times, which inevitably means using voice input or fairly simple tapping and/or swiping gestures.

Development Tit Bits

This section highlights key concepts in order to get started with your app development.

Eclipse and Android Studio work well as an IDE, though Google wholeheartedly recommends Android Studio for app development. The SDK Manager in Android can be used to download API Level 20 – that’s 4.4 KitKat Wear:

08

Through Android Studio you can add Android Wear support to your existing apps or create an entirely new project. Since Android Studio incorporates a module model, both the Phone and Wear modules fall under a single project.

Here’s how you create a new project: click on File > New Project. On the next screen, select the form factor, along with any other form factor you might be working on.

09

Choose all your options, and a project is generated for you. There are two Android project modules: Mobile and Wear. As the name implies, Mobile runs on a phone device and Wear runs on an Android Wear device.

Keep in mind you need to package the mobile and Wear app into the application APK; they cannot be packaged separately before being posted on the Play Store. Once a user installs the APK on their phone, the Wear app automatically transfers over to the paired Wear device.

It should be kept in mind that the default project that’s generated by Android Studio doesn’t really work any magic; during tests, you’ll be mostly writing your own code. Writing code will largely depend on what you want the “wearable” aspect of the app to do.

Notifications

You can look at Android Wear development from two standpoints: Notifications and Android Wear Apps (packaged through the APK file).

Users who have the Play Store-installed Android Wear app and have paired it up with their Wear device, get notifications on an “as is” basis:

010

Being said though, at times modifications are needed for apps to be highly useful on Wear. You can have notifications prompt users only on a phone, wearable, or both. In addition, as mentioned earlier, developers should keep in mind how to best exploit the UI/background image, notification text and title etc.

For handheld notifications that are sent to a wearable device, Google has recommended the NotificationCompat.Builder class. You will also find this in the Android Support Library; subsequently, it needs to be added to your project.

With respect to Android Studio, this compile time dependency needs to be added to your build.gradle file found in the mobile module:

01

It’s time to build a notification, so here’s the code you’re going to experiment with in the mobile application:

02

After this, you can trigger the notification, on the basis of your own logic:

03

When users receive notifications on their Wear device, they can open the Pending intent activity on their phone: either through touch or swiping. This will prompt an Open action.

Let’s say you want the notification to appear as an extension only on the user’s phone, you can build that by specifying: .setLocalOnly(true).

This example only shows one card, but you can also check out how to work on multiple pages or stacked notifications.

Wearable Applications

Even though Android Wear’s notification support works well with phones, at times, it is not very practical. Consider the following scenarios:

  • Launching an activity on Wear if some data is available on the phone
  • Sending messages from Wear to phone, which executes an activity or background function
  • Creating custom UI on Wear
  • Writing apps that are launched and run on Wear, which are also capable of accepting user voice input to drive certain actions.

The above and much more can be achieved, only if you have a good understanding of some of the building blocks of Wear APIs.

Data Exchange and Connection

The ‘use’ cases we highlighted above incorporate a common theme where both the smartphone and Wear device must have a mechanism through which a connection can be established, after which messages can be exchanged back and forth. And naturally, the desired actions can be triggered within the devices involved.

This connection is established through GoogleAPIClient:

04

The connection can be established or closed under the right Activity Lifecycle method:

05

After establishing a connection, you can check out several examples of APIs to help you send and sync data between devices:

  • Node: This API tracks connections or disconnections between two devices through one of the NodeListener interface methods. This is also a good way to get a list of all connected nodes.
  • Message: This API can be used to send short messages to either device. The receiving device needs a listener (MessageListener) in order to receive the message.
  • Data: This is used to sync data between the two devices. The sync mechanism is provided on both ends. For receiving messages, the DataListener interface must be implemented.  It’s recommended you create an instance of WearableListenerService on both ends and listen for events you are most interested in.

Here are the Data Layer Interfaces. Use the ones best suited to your project:

06

Remaining functionality – actions that need to be taken when it comes to particular messages – depends solely on the functionality of your application.

A Typical Example

Let’s put it all in context – an example of an app with both phone and Wear components. Putting things simply, let’s give the phone application a single activity name such as MainActivity.java. The layout has a button; when users click it, a message gets sent to the Wear app.

Initially, we will look at MainActivity.java in the phone application part:

07

On the Wear end, we wrote down a service extending WearableListenerService, if you recall. Use this service to initialize GoogleAPIClient and other callbacks such as GoogleAPICLient.ConnectionCallbacks.

And at last, we provide an implementation using:

08

Voice Actions and Custom UI

Apart from data APIs, Wear also lets developers create customer UIs using an unofficial library.

Voice integration lets users provide voice input which is interpreted as text. Incorporating the Demand pattern, users can invoke a specific action. As you know, Wear comes ready with system-integrated actions like “send a message” or “take a note”; as a developer you can have your app register standard intents in the Manifest file:

09

You can also enable users to start an activity through voice input – “Start [ActivityName]” on the Wear device. Provide a label attribute for that activity (in the Manifest file):

010

What to Take Way from This

Android Wear is an excellent platform for building apps for the first wave of compatible devices – smartwatches.

Google has been repeatedly placing stress on how devs need to keep user requirements in mind and tailor their apps based on this vision – make existing apps Wear-friendly through notifications thereby keeping the barrier to writing apps at a minimum. Therefore, developers must not think along the “reinvent the wheel” lines.

One look at the Play Store will show you the growing number of apps that are Wear-ready, which also includes a major rise in watch faces – a user favorite. The number of vendors announcing plans for Wear devices is ever increasing, especially given Android’s global market reach – we’d say now is an opportune time for developers to invest their efforts in the Wear platform.

Comments are closed.

Infographic
Get Free Quote

© 2008-2016 Social Cubix. Designs, content and logos are trademarks of Cubix Labs, Inc. Terms of use | Privacy policy

KeywordsReferer