Android Wear — Advanced Considerations

In previous articles we learnt how to add a Wearable app to your already existing Android app and how to access the Data Layer API.

If you want to learn few tricks and things to bear in mind keep reading :)

Notifications

Notification Actions

Note that when you use addAction in the WearableExtender, none of the regular addAction calls will be shown on the wearable and none of the wearable addAction calls will be shown on the phone. They are decoupled from each other now.

Notification Background

Android Wear automatically uses the largeIcon of the notification as a background image. This image is usually 64x64px because it’s displayed quite small in the notification bar (status bar).

The WearableExtender provides a method to set the background which is going to be displayed on the wearable device. That image is going to be sent to the wearable, it can be any size. However, if the image is too big you can overwhelm the memory of the smartwatch. Instead, it’s recommended to use a 400x400px image for a static background or a 640x400px if you want to have image parallax added where the left and right edges simulate background movements.

Make sure you store these resources in the drawable-nodpi folder so you know the framework is not going to resize it.

Notification Stack

When you stack notifications and you set the group for a notification, you can also say which notification is the summary of that group. You can do it with setGroupSummary.

Notification summaryNotification = new NotificationCompat.Builder(context)
.setContentTitle(...)
.setSmallIcon(...)
...
.setGroup(GROUP_KEY)
.setGroupSummary(true)
.build();

The summary will appear on the phone while the other group items are showing on the Android Wear device.

Notification only on the mobile phone

NotificationCompat.Builder provides the method setLocalOnly that allows you to display a notification only on the phone.

Notification only on the Wearable device

You cannot do it from the Mobile project. You should create the notification in the Wearable project (you need a Wearable app in this case). This notification (which is programmed in the same way) is never synchronised over to the phone.

Wear App

Running the Wear App

As we saw in the Add a Wear app to your Mobile one article, we can embed the wear project into the mobile one as follows:

dependencies {
...
wearApp project(':wear')
...
}

We should know that that only happens on release mode. There’s no app embedding on debug mode.

If you try to debug packaging installation problems you can use adb logcat and it will tell you what the problem is.

adb logcat | grep WearablePkgInstaller

Layout for Round and Square screens

BoxInsetLayout is based on a layout (usually made for square smartwatches) that it’s going to be adapted to the round one. For square devices, it just displays the content on the screen. For round devices, it adds padding to fit the layout on the screen as you can see in the image below.

<android.support.wearable.view.BoxInsetLayout>
...
   <LinearLayout
...
app:layout_box="all">
</android.support.wearable.view.BoxInsetLayout>

Other option could be a Round-only layout. The design works for both round and square screens. It’s the opposite idea of BoxInsetLayout. The corners of the square screens are wasted though.

WatchViewStub lets you specify different layout definitions for square and round screens.

Always-on feature allows your app to control what it’s shown on the watch while it’s in ambient mode. It’s very similar to the watch face lifecycle.

Go to the Android documentation to know more about it.

Hope these tricks and facts are helpful to improve your Wearable UX!

Thanks for reading,

Manuel Vicente Vivo