SHORTCODE TESTING POST

Bear balls
Rahsaan
AEOC clip
Art Ensemble of Chicago

Today, Google announced Lollipop for Android Wear devices. One of the most anticipated features included in this update is official support for developing watch faces. This is such an exciting feature that many developers, Two Toasters included, have already released unofficial watch faces (such as Chron) using unofficial methods. Two Toasters was lucky enough to get early access to the watch face APIs and had the opportunity to partner with Specialized, a brand well known to cyclists everywhere, to develop the Specialized Bikes Watch Face that is uniquely suited to cyclists. Now that official support exists for watch faces, let me show you how to implement one the proper way so you can gain all of the benefits and features from using the new APIs.

Wear Watch Face API Overview

An Android Wear watch face is a Wear app installed on the watch which implements a service that is an extension of an Android live wallpaper. The WatchFaceService class provides additional lifecycle methods used by wearables and helps accommodate the additional design considerations that must be made. For debugging purposes, the Wear app can be installed by sending the Wear APK, signed with the debug key, directly to the wearable via ADB. For release, a release-signed Wear APK can be built and packaged by the Android build system inside of a release-signed mobile APK. When the release-signed mobile app is installed on a mobile device by the Play Store, the mobile device will send the Wear app to the connected wearable. One note here is that the mobile and Wear apps must be signed with the same key. Also, this method must be used for distribution through the Play Store. Although no activities are required for implementing a watch face, many users will want to customize their watch face. The watch face APIs provide developers two ways that they can allow their users to modify watch face settings. Users will be able to change some settings on the wearable by tapping on a settings icon below the watch face preview in the watch face picker when implemented by the developer. In addition, users will be able to customize the full set of settings by tapping the settings icon overlaid on top of the watch face preview in the Android Wear companion app when implemented by the developer. Each of these two settings screens are activities that can be declared in the respective Android manifests.

Project Setup and Manifest Config

The first step for creating a watch face is setting up a new project with two modules; we’ll call them mobile andwear. Both of these modules will be Android apps, so we will apply the com.android.application plugin to both modules in their build.gradle files. It is important that both modules have the same package name, so it is best to externalize the package name to a gradle.properties file and have the build.gradle for both modules and to read the value from there. If your watch face will have settings screens, then it will be helpful to also create a shared common module that consists of an Android library project that both the mobile and wear modules depend upon.

Wear Module

For the wear module, we want to set the minSdk to 21 since we require the watch face APIs in Lollipop. In the dependencies section of our build.gradle, we’ll want to add compile "com.google.android.support:wearable:1.+" so that we have access to the wearable support library. We’ll need to require the com.google.android.permission.PROVIDE_BACKGROUND and android.permission.WAKE_LOCKpermissions in our wear manifest file. We’ll also add the <uses-feature android:name="android.hardware.type.watch" /> line so that the Wear app can only be installed on wearables. The last required configuration item we need to add is the service that will display the watch face. The items to notice in the service declaration below are the allowEmbeddedtaskAffinity, and permission attributes and the intent-filter declaration that are required for services providing watch faces.

The Evening Star

For the wear module, we want to set the minSdk to 21 since we require the watch face APIs in Lollipop. In the dependencies section of our build.gradle, we’ll want to add compile "com.google.android.support:wearable:1.+" so that we have access to the wearable support library. We’ll need to require the com.google.android.permission.PROVIDE_BACKGROUND and android.permission.WAKE_LOCKpermissions in our wear manifest file. We’ll also add the <uses-feature android:name="android.hardware.type.watch" /> line so that the Wear app can only be installed on wearables. The last required configuration item we need to add is the service that will display the watch face. The items to notice in the service declaration below are the allowEmbeddedtaskAffinity, and permission attributes and the intent-filter declaration that are required for services providing watch faces.

Transcript:

My hours were…

Transcript:

My hours were…

Downloads
This page was added on 10/02/2015.

No Comments

Start the ball rolling by posting a comment on this page!

Add a comment about this page

Your email address will not be published.