Android Wear

Nishant Srivastava

Android Dev/Interaction Designer

Organizer@GDG New Delhi

Information that moves with you

So what is Android Wear ?

Android Wear organizes your information, suggests what you need, and shows it to you before you even ask. Get messages from your friends, meeting notifications, and weather updates at a glance....

Android Wear is a customised android version for wearable devices such as smart watches

OK, so what can it do for me ? 

Whaaaa..what did you just say ..?

  • Notification, most useful information in a managed manner.

  • Voice Search, straight answers to questions

  • Sensors, monitors Health & Fitness

  • Next Multi-Screen Technology

How it Works

  • Requires  android(>=4.3) phone/tablet (referred to as handheld)
  • Requires "Android Wear" app to be installed on the handheld
  • Handheld and Wearable communicate each other via Bluetooth
    (wearable does not connect to internet on its own)

Application Packaging and Publishing

  • When publishing to user, package a wearable app inside a handheld app
  • Wearable app  will be installed on user's wearable automatically when user install handheld app from Google Play Store
  • Package name is mandatory to be same for handheld and wearable app both

What you can DO with it ?

  • Receive Notifications and react to them on the wearable
  • Control apps on the handheld via the wearable
  • Run wearable specific apps ( i.e Compass, Heart Rate Monitor,etc )
  • Voice Search and Voice Actions...and many more...

Lets Get Started !

http://developer.android.com/wear

Prerequisites:

  1. Java 6 or higher
  2. Android Studio/ Eclipse (or ADT)
  3. Android SDK Tools with the following packages
  • Android 4.4W (API Level 20)
  • Extras: Android Support Repository, Android Support Library, Google Play services 

http://developer.android.com/sdk/installing/index.html?pkg=tools

Get Started!

  1. If not using a device get the emulator image from the Android SDK Manager - again for API Level 20!(Intel image requires HAXM Installer in Extras)
  2. Don’t forget to download samples for API Level 20!
    [android-sdk]/samples/android-20/wearable
  3. Download the Android Wear App on your device 
    https://play.google.com/store/apps/details?id=com.google.android.wearable.app&hl=en

...we have a problem
Eclipse.

Working on eclipse for developing apps for Android Wear is a very tricky job (period).


For those of you who like to play with FIRE , and plunge into the pit of Hell ...well , good news you can still build Android Wear apps on Eclipse. Follow the below blog to setup and build Android Wear Apps :
https://medium.com/@tangtungai/how-to-develop-and-package-android-wear-app-using-eclipse-ef1b34126a5d

Basic Setup

  • Install Android Studio 
  • Install Android Wear support packages and system image using the Android SDK Manager
         -Android 5.0 (API 21)
         -Android 4.4W (API 20)
         -Android SDK Tools rev23 or later
         -Android Wear ARM/Intel system image
         -Android Support Library (20 or later)
         -Android Support Repository (6 or later)
  • Setup and Android Wear emulator using the Android AVD Manager
  • Start the emulator
  • Download, install and start the Android Wear companion app
  • Enable USB Debugging on your handheld device
    ...continued...

Basic Setup ( Contd..)

  • Connect your handheld device to computer via the USB cable.
  • Open TCP port 5601 on your computer.The Android Wear Emulator uses this port to communicate with the handheld device.
         
    ./adb -d forward tcp:5601 tcp:5601
  • On the handheld device launch the Android Wear companion app
    on first launch, enable Android Wear app as the notification listener , by following the onscreen instructions.
  • Now connect your emulator with the handheld device, by selecting the watch icon in the Action bar 

Notifications

Notifications are one of the two major design principles of Android Wear: Suggest and Demand

Suggest : Context Stream

  • Context stream, which is a vertical list of cards, much like Google Now 
  • Interact with the cards by swiping them vertically
  • Only one card will be displayed at a time.
  • Add cards to the context stream by creating and delivering notifications. Use NotificationCompat.Builder to create basic notifications 
  • To use Android Wear specific features like pages or actions, or to customize the look of cards on the context stream, use WearableNotifications.Builder

Suggest : Context Stream

int notificationId = 001;

// Build intent for notification content
Intent viewIntent = new Intent(this, ViewEventActivity.class);
viewIntent.putExtra(EXTRA_EVENT_ID, eventId);
PendingIntent viewPendingIntent =
        PendingIntent.getActivity(this, 0, viewIntent, 0);

NotificationCompat.Builder notificationBuilder =
        new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.ic_event)
        .setContentTitle(eventTitle)
        .setContentText(eventLocation)
        .setContentIntent(viewPendingIntent);

// Get an instance of the NotificationManager service
NotificationManagerCompat notificationManager =
        NotificationManagerCompat.from(this);

// Build the notification and issues it with notification manager.
notificationManager.notify(notificationId, notificationBuilder.build());

Here is a short snippet that shows how to create a notification:

Demand : Cue Cards

  • Users can initiate an interaction with their device by using the cue card
  • Swiping up on the cue card will reveal a number of actions that can be executed by tapping them or speaking them 

A word of advice, make sure all information you deliver follows the principle of being timelyrelevant, and specific.

DEMO

Hello World Notification

Sending and Syncing Data

-Messaging API

        -Fire and Forget, 1 way request

        -Can send only a String

       -Use Case  example : Control Media Player from wearable

-Data API

        -Sync data between handheld & wearable

        -Payload is a byte array( 100KB per Item), But you can use
         map interface to access data

        -Use Case example : Send Photo preview to wearable from
         handheld

Questions ?

Nishant Srivastava

nishant@silverpush.co

http://slides.com/nisrulz/kickstartandroidwear#/

Kickstart Android Wear

By Nishant Srivastava

Kickstart Android Wear

Kickstart into Android Wear World

  • 2,161