Android Wear Introduction

Android Wear expands the Android platform to wearables. We are beginning this discussion with a well known wearable – watches. You’ve already heard about Android Wear: Watches, Moto360 and all. It focuses on timely information, delivered when it is most relevant. 

In this tutorial we will learn Android Wear aspects through setting up your IDE. Writing code and testing your code on real Android Wear devices or emulators will be covered in my next tutorial.

Before writing code for Android wear directly, we will learn about design, guidelines and concepts of android wear. The Android Wear UI includes two main functions i.e. Suggest and Demand.

1.) Suggest: The Context Stream
The context stream is a vertical list of cards, 
each showing a useful or timely piece of information. Our application can create cards and inject them into the stream accordingly.
 Cards in the stream can be swiped horizontally and reveal more pages 
or buttons allowing the user to act upon notification. Cards are dismissed by left to right swiping, removing them until new notification
 arrives from the same application with new information to display.

2.) Demand: The Cue Card
The cue card will open and swiping up shows a list of suggested voice commands, which can also be tapped. Each voice command activates a specific type of intent. We as developers should match our applications to some of these intents so that users can complete tasks using these voice commands. Multiple applications may register for the same single voice intent, while the user will have the opportunity to choose which application they prefer to use.

Explore more on the video below:

Android studio is the best and most recommended IDE to develop the android wear app just to make sure we have all the libs and setups we need to start developing. Also because 
Android studio provides project setup, library inclusion, and packaging conveniences that aren’t available in ADT.

Setting up an Android Wear emulator is quite easy and is same as we setup our Android emulators. Once we are done with setting up the emulator we need to launch them for further configuration. This is very important and must do thing because it will allow our Android handheld to connect with the Android Wear emulator. Follow the steps below:

1.) Start the emulator by selecting the virtual device we just created and wait until the emulator shows the Wear home screen.

2.) To pair our handheld with the emulator we need to install the Android Wear app from Google Play.
3.) Then we need to connect the handheld to machine through USB and forward the AVD’s communication port to the connected handheld device

 

adb -d forward tcp:5541 tcp:5541

 

 

We need to follow these steps every time the handheld is connected.

4.) Start the Android Wear app on your handheld device and connect to the emulator. On tapping the menu on the top right corner of the Android Wear 
app to select “Demo Cards”, the cards selected appear as notifications on the home screen of the emulator.

Wen you Create a Android Wear project using your AndroidStudio project setup You will have two modules in your project “Mobile” and “wear”. Lets have a look on the manifest file:

 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myandroidwear" >

<uses-feature android:name="android.hardware.type.watch" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.DeviceDefault" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

 

 

You will see there is just one extra line added in the wear manifest which is to tell the system watch type wearable will be embedded.

The first hello wear world will be covered in the upcoming post.

Leave a Comment: