38. Available commands
#androidwear
● Call a car/taxi
● Take a note
● Set alarm
● Set timer
● Start/Stop a bike ride
● Start/Stop a run
● Start/Stop a workout
● Show heart rate
● Show step count
44. Create and issue the notification
Notification mNotification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Simple Notification")
.setContentText("Just a title, a text and an icon")
.build();
NotificationManagerCompat mNotificationManager =
NotificationManagerCompat.from(this);
mNotificationManager.notify(mNotificationId, mNotification);
MobileActivity.java
45. Add a “open on device” action
Intent intent = new Intent(this, NotificationIntentActivity.class);
intent.putExtra("EventID", 1);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
Notification mNotification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Simple Notification")
.setContentText("Just a title, a text and an icon")
.setContentIntent(pendingIntent)
.build();
MobileActivity.java
46. Add a custom action
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri position = Uri.parse("geo:0,0?q=41.109388,16.878843");
intent.setData(position);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
Notification mNotification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Simple Notification")
.setContentText("Just a title, a text and an icon")
.addAction(R.drawable.ic_location, "Check your position", pendingIntent);
.build();
MobileActivity.java
47. Add a custom action ONLY ON WEAR
NotificationCompat.Action mAction =
new NotificationCompat.Action.Builder(
R.drawable.ic_location,
“Check your position”
mPendingIntent).build();
NotificationCompat.WearableExtender mExtender =
new NotificationCompat.WearableExtender()
.addAction(mAction);
Notification mNotification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Simple Notification")
.setContentText("Just a title, a text and an icon")
.extend(mExtender)
.build();
MobileActivity.java
48. WearableExtender
NotificationCompat.WearableExtender mExtender =
new NotificationCompat.WearableExtender()
.addAction(mAction)
.setBackground(myBitmap) //set a background image
.setHintHideIcon(true); //hide the notification icon on the card
Further info about the WearableExtender class at http://bit.ly/1sA2DsL
MobileActivity.java
49. Voice Inputs
● Handled by the Cue Card
● Can provide a list of predefined commands
● Use RemoteInput class to request user
interaction via voice commands
50. Prepare Voice Input
public static final String EXTRA_VOICE_REPLY = “user voice”;
public String[] mChoices = getResources().getStringArray(R.array.choices);
RemoteInput mVoiceInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
.setLabel(“Reply”)
.setChoices(choices) //optional
.build();
...let’s add it to a notification
MobileActivity.java
51. Prepare Voice Input
NotificationCompat.Action mVoiceAction =
new NotificationCompat.Action.Builder(R.drawable.icon, “Reply”,
mPendingIntent)
.addRemoteInput(mVoiceInput)
.build();
NotificationCompat.WearableExtender mExtender =
new NotificationCompat.WearableExtender()
.addAction(mVoiceAction);
Notification mNotification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle(R.string.notification_title)
.setContentText(“Here’s the notification text”)
.extend(mExtender)
.build();
MobileActivity.java
53. Paged Notifications
NotificationCompat.Builder mFirstPageBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.icon)
.setContentTitle(R.string.title)
.setContentText(“This is the first page”);
Notification mSecondPage =
new NotificationCompat.Builder(this)
.setContentTitle(R.string.titletwo)
.setContentText(“This is the second page!”)
.build();
Notification mNotification = new NotificationCompat.WearableExtender()
.addPage(mSecondPage)
.extend(mFirstPage)
.build();
MobileActivity.java
54. Stacked Notifications
public static final String APP_GROUP = “App Notifications”;
Notification mNotification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Simple Notification")
.setContentText("Just a title, a text and an icon")
.setGroup(APP_GROUP)
.build();
MobileActivity.java
55. Stacked Notifications, GroupSummary
public static final String APP_GROUP = “App Notifications”;
Notification mSummaryNotification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(largeIcon)
.setStyle(new NotificationCompat.InboxStyle()
.addLine("First Notification Hi, I'm a notification")
.addLine("Second Notification Yay, here's the second one!")
.setBigContentTitle("2 Notifications from your app")
.setSummaryText("com.example.app"))
.setGroup(GROUP_ID)
.setGroupSummary(true)
.build();
MobileActivity.java
56. Write your wear apps almost like
phone apps
Stand Alone
Apps
57. ● Access to device’s sensors
● A wearable app is more useful in some
situations
● Quick info without pulling out the phone
Stand Alone
Apps
58. ● Short Timeline
● Needs a companion app because of Playstore
compatibility
● Less functionality than a phone app
● DON’T PORT YOUR UI ON A WEARABLE!!!
Stand Alone
Apps
61. Phase 1: Prepare your devices
● Pair your phone with wear/emulator
● Enable Bluetooth debug in wear app
● Enabe Bluetooth debug on the wear device
● Enable Developer Options on wear (as easy as on the phone)
● Connect the phone to the PC
● Open terminal and launch one of the following commands
adb -s <phone id> forward tcp:5601 tcp:5601
adb forward tcp:4444 localabstract:/adb-hub; adb
connect localhost:4444
63. ● Notifications:
● Data Layer:
● UI:
If you don’t need to share notification between mobile and wear, use the
standard notification class, otherwise use NotificationCompat
Use only if you need to sync data or send messages between mobile
and wear. Remove if not necessary
You should use it if you want to create beautiful UI that
really rocks!
Docs available at http://bit.ly/1p8ekRu
Choose your libraries
68. Built-in Intents
<activity android:name=”.NoteActivity”>
<intent-filter>
<action android:name=”android.intent.action.SEND”/>
<category android:name=”com.google.android.voicesearch.SELF_NOTE” />
</intent-filter>
</activity>
A complete list of built-in intents can be found at http://bit.ly/1p8omlo
Add Voice Commands
.Manifest