2. Learn more at www.gdg-sg.org/member
• Keep up to date with Google products and technologies
• Make new friends that are also passionate about technology
• Interact with Googlers
• Access to selected exclusive Google events
• Find jobs and developers related to Google products
• Contribute to developer community
3. Learn more at www.gdg-sg.org/member
Because pictures speak a thousand words
4. Learn more at www.gdg-sg.org/member
For more membership details,
Visit http://bit.ly/gdg-sg-members
Get started today with just your email.
5. What is Android Wear?
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
6. What is Android Wear?
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
Notifications
Apps on Wear
Android Fit
7. What is Android Wear?
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
8. What is Android Wear?
Requires Android 4.3 and above Android
device
Latest Google Play Services and Android Wear
app from Google Play installed
Internet and connectivity over bluetooth from
paired device
Limited function when connection is lost
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
9. Getting Started – Install
SDK
Install the Android Wear SDK Tools from ADT
• Android ADT Revision v22.6 and above
• Android Wear ARM EABI v7a system image
• Update Android Support Library
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
10. Getting Started – Install
emulator
To install and test Android Wear emulator, you
need to (visit http://javapapers.com/android/android-wear-getting-started-tutorial/
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
for full details)
1) Sign up for developer preview
http://developer.android.com/wear/preview/signup.html
2) Create AVD
3) Connect Android device over adb (adb -d forward tcp:5601
tcp:5601)
4) Install Android Wear Preview from Google Play
11. Design for Wear
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
Wear apps should be
• Launched automatically
• Glance-able
• Works like a personal butler
• Zero to low interactions
12. Design for Wear
Two ways you can think of Wear
Interactions
• Extension of existing Android app notifications to work
better on Android Wear (existing notifications on phone
already appears on Wear)
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
• Android Wear specific app
13. Notifications for Wear
Extending your existing notifications to
Wear
• You can add voice input/actions directly from Wear
• You can add additional content in pages
• By swiping left/right on the wearable
• You can stack multiple notifications
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
14. Notifications for Wear
Adding actions to Wear (It is very
simple)
• The same code before works the same on Wear (Including
notification actions, big view)
• Use NotificationCompat.WearableExtender() for Wearable-only
options (Appears only on Wear, not on phone)
• You can use addRemoteInput(remoteInput) to prompt user
for voice input
• P.S. Always use the NotificationManagerCompat instead of
NotificationManager (to support 4.1 and above features)
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
15. Notifications for Wear
Adding actions to Wear (Eliza sample
cNootidficaetio)nCompat.Builder builder = new NotificationCompat.Builder(this) // All the usual
stuffs
.setContentTitle(getString(R.string.eliza))
.setContentText(mLastResponse)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.bg_eliza))
.setSmallIcon(R.drawable.bg_eliza)
.setPriority(NotificationCompat.PRIORITY_MIN);
Intent intent = new Intent(ACTION_RESPONSE); // Intent to do your stuff
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent,
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT);
Notification notification = builder
.extend(new NotificationCompat.WearableExtender() // New notification
extension for Wear
.addAction(new NotificationCompat.Action.Builder(
R.drawable.ic_full_reply, getString(R.string.reply), pendingIntent) //
Get voice input
.addRemoteInput(new RemoteInput.Builder(EXTRA_REPLY)
.setLabel(getString(R.string.reply))
.build())
.build()))
.build();
NotificationManagerCompat.from(this).notify(0, notification);
16. Notifications for Wear
Extending your existing notifications to
Wear
• You can add voice input/actions directly from Wear
• You can add additional content in pages
• By swiping left/right on the wearable
• You can stack multiple notifications
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
17. Notifications for Wear
Adding additional content in pages
(many at one time)
• For example, showing results of nearby search
• First, create an array list of notifications
• Next, generate a notification for each page you want to
display, and add them to your array list
• Last, use .addPages(List<Notifications>)to parse in your array
list
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
18. Notifications for Wear
Adding additional content in pages (one
at a time)
• First, create the main (first) notification builder
• Next, create the new notification you want to insert
• Last, use .addPage(Notification) to add your notification
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
19. Notifications for Wear
Adding additional content in pages
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) //
Main
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
.setSmallIcon(R.drawable.new_message)
.setContentTitle("Page 1")
.setContentText("Short message")
.setContentIntent(viewPendingIntent);
Notification secondPageNotification = new NotificationCompat.Builder(this) // Second
Notification
.build();
Notification twoPageNotification = new WearableExtender()
.addPage(secondPageNotification) // Add second notification to main
.extend(notificationBuilder)
.build();
notificationManager = NotificationManagerCompat.from(this);
notificationManager.notify(notificationId, twoPageNotification);
20. Notifications for Wear
Extending your existing notifications to
Wear
• You can add voice input/actions directly from Wear
• You can add additional content in pages
• By swiping left/right on the wearable
• You can stack multiple notifications
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
21. Notifications for Wear
Stacking multiple notifications
• Use .setGroup(String key) to group your new notification to
existing group
• Use notify() to send the notification to Wear
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
22. Notifications for Wear
Stacking multiple notifications
final static String GROUP_KEY_EMAILS = "group_key_emails"; // Key for group
ID
Notification notif = new NotificationCompat.Builder(mContext)
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
.setContentTitle("New mail from " + sender1)
.setContentText(subject1)
.setSmallIcon(R.drawable.new_mail);
.setGroup(GROUP_KEY_EMAILS) // Set group ID into notification
.build();
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(this);
notificationManager.notify(notificationId1, notif); // Send out the notification
23. Design for Wear
Two ways you can think of Wear
Interactions
• Extension of existing Android app notifications to work better
on Android Wear (existing notifications on phone already
appears on Wear)
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
• Android Wear specific app
24. Wear App API Architecture
Phone APK Wear APK
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
25. Wear App API Architecture
Node API
- Inform when Wear is connected
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
Message API
- Manage API calls
between devices
Data API
- Centralized data store
managed by GPS
GPS
Magic
26. Wear App API Architecture
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
27. Wear App API Architecture
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
28. Wear App API Architecture
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
29. Wear App API Architecture
To start communicating with the Wearable, we
need to initialize the GoogleApiClient on the
phone APK
mGoogleApiClient = new GoogleApiClient.Builder(this)
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
.addApi(Wearable.API)
.build();
mGoogleApiClient.connect();
30. Wear App API Architecture
WearableListenerService will handle all the
callbacks from Google Play Services on wear
// Insert the service into the manifest of the Weak.apk, in this case name it
// AppListenerService (subclass of Abstract class WearableListenerService)
<service
android:name=“.AppListenerService”>
<intent-filter>
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
<action
android:name=“com.google.android.gms.wearable.BIND_LISTENER”/
>
</intent-filter>
</service>
31. Wear App API Architecture
In AppListenerService.java, you can manage
the callbacks from Node, Data and Message
listeners
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
32. Add Voice Action to Wear
You can trigger your app through voice actions
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
33. Add Voice Action to Wear
Just add the intent filter to your WearActivitiy
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
<activity
android:name=“MyWearActivity”>
<intent-filter>
<action android:name=“android.intent.action.SEND”/>
<category android:name =
“com.google.android.voicesearch.SELF_NOTE”/>
</intent-filter>
</activity>
34. Add Voice Action to Wear
Available commands today (approval process
similar to Google Glass)
More details:
https://developer.android.com/training/wearables/apps/voice.
html
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
35. Add Voice Action to Wear
Alternatively, you can use “Start
MyVoiceAction” to launch your app. Just
declare in manifest under label.
<activity android:name=“MyWearActivity" Android:label=“MyVoiceAction">
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
36. Add Voice Action to Wear
For additional input, say “Take a note”, follow
by user voice input, you can get the voice
input by calling startActivityForResult
// Create an intent that can start the Speech Recognizer activity
private void displaySpeechRecognizer() {
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
Intent intent = new
Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
startActivityForResult(intent, SPEECH_REQUEST_CODE);
}
37. What is Android Wear?
Code Demo Time
Introduction to Android Wear by Chua Zi Yong -
https://plus.google.com/+ZiYongChua
38. Learn more at www.gdg-sg.org/member
• Keep up to date with Google products and technologies
• Make new friends that are also passionate about technology
• Interact with Googlers
• Access to selected exclusive Google events
• Find jobs and developers related to Google products
• Contribute to developer community
39. Learn more at www.gdg-sg.org/member
Because pictures speak a thousand words
40. Learn more at www.gdg-sg.org/member
For more membership details,
Visit http://bit.ly/gdg-sg-members
Get started today with just your email.
Editor's Notes
Is it possible to run Android Wear only app? I.e. no mobile client, standalone offline app
How to manage the notification and icon on the Wear app itself
Is it possible to run Android Wear only app? I.e. no mobile client, standalone offline app
How to manage the notification and icon on the Wear app itself
Is it possible to run Android Wear only app? I.e. no mobile client, standalone offline app
How to manage the notification and icon on the Wear app itself
Is it possible to run Android Wear only app? I.e. no mobile client, standalone offline app
How to manage the notification and icon on the Wear app itself