Thursday, September 11, 2014

Developing a Simple Android Wear Application: Part 1

This post will walk through the steps involved in creating a simple Android Wear application. I will be using the Balloon Pop Android app as the code example.

In order to get started you need to have already completed the following steps:
  1. Download the Android SDK
  2. Configure a Wearable device or Emulator
  3. Install the latest platforms and tools (either ADT/Gradle)

image 1: main app layout
The application is comprised of two modules: app and wear.

The app portion is primarily required in order to deploy the application on Google Play.  It simply contains one Activity with a basic layout that notifies the user of the fact that it is a wearable application. (see image 1) 

The most important part of the module is that it includes the wear app as a dependency, this way the wearable app will be automatically installed when the main application is installed. You can read more about your packaging options here.

The wear portion contains the activities and game logic that run on the actual wearable device.  It uses the wearable support library in order to take advantage of two UI components: the BoxInsetLayout and the WearableListView.

The BoxInsetLayout is very useful for supporting both rectangular and circular devices because it allows you to define boundaries for its elements.  We use it for the "Addition" and "Subtraction" views so that all three balloons are displayed in the viewable area.


Part 2 will cover the WearableListView provided in the support library. This post was based on the Balloon Pop Android application available on Google Play.

No comments:

Post a Comment