Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android Wear Development

David Vávra
September 05, 2014

Android Wear Development

David Vávra

September 05, 2014

More Decks by David Vávra

Other Decks in Technology


  1. Hardware BT Mic PM HR Display Battery Additional Price Available

    Samsung Galaxy Gear Live x x x x 320x320 AMOLED square 300 mAh: 1.5 day Charging cradle, IP67 $199 Google Play now LG G Watch x x x 280x280 LCD square 400 mAh: 1.5 day Charging cradle, IP67 $229 Google Play now Moto 360 x x x x 320x290 LCD round 320 mAh: 1 day Wireless charging, light sensor, IP67 $250 US now, UK October LG G Watch R x x x x 320x320 OLED round 410 mAh: 1.5 day Charging cradle, Barometer, IP67 $299? October Sony SmartWatch 3 x x x x 320x320 transflectiv e square 420 mAh: 2 days? microUSB, GPS, IP68, NFC, IP55 $299 autumn Asus ZenWatch x x x x 320x320 s AMOLED 369 mAh: 1 day Charging cradle, curved screen $260 autumn BT=Bluetooth Low Energy, PM=pedometer, HR=heart rate monitor, all=gyroscope, accel., compass
  2. Design principles Design for big gestures Do one thing really

    fast Don’t be a constant shoulder-tapper Don’t stop the user
  3. Extending notifications // Create a WearableExtender to add functionality for

    wearables NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender() .setHintHideIcon(true); // Create a NotificationCompat.Builder to build a standard notification // then extend it with the WearableExtender Notification notif = new NotificationCompat.Builder(mContext) .setContentTitle("New mail from " + sender) .setContentText(subject) .setSmallIcon(R.drawable.new_mail); .extend(wearableExtender).build();
  4. Paging notifications // Add second page with wearable extender Notification

    twoPageNotification = new WearableExtender() .addPage(secondPageNotification) .extend(notificationBuilder) .build(); // Issue the notification notificationManager = NotificationManagerCompat.from(this); notificationManager.notify(notificationId, twoPageNotification);
  5. Stacking notifications Bitmap background = BitmapFactory.decodeResource(getResources(), R.drawable.ic_background); NotificationCompat.WearableExtender wearableExtender =

    new NotificationCompat.WearableExtender() .setBackground(background); // Create an InboxStyle notification Notification summaryNotificationWithBackground = new NotificationCompat.Builder(mContext) .setContentTitle("2 new messages") ... .extend(wearableExtender) .setGroup(GROUP_KEY_EMAILS) .setGroupSummary(true).build();
  6. Native apps • packaged into phone app • Android 4.4

    KitKat ◦ access all Android APIs except internet, bluetooth and usb • are launched: ◦ from your Service (custom notification) ◦ using voice ◦ third-party launcher • are exited: ◦ swipe right ◦ palm ◦ timeout ◦ long press
  7. UI for rounded screens • android: windowOverscan=tr ue ◦ layout_gravity=”

    center_vertical” • WatchViewStub ◦ different layout for round and square • BoxInsetLayout ◦ same layout for both ◦ wearable: layout_box=”left|right”
  8. Voice input • System provided actions - Intents ◦ take

    a note, set an alarm, start a run, … • App provided voice action - MAIN Intent ◦ “OK Google, start <activity_name>” • Free-form speech input ◦ standard Intent
  9. Sending and syncing data • Only way of communicating with

    the phone • Simple byte[] data, serialization required • Managed by Google Play Services • Teleport library ◦ https://github.com/Mariuxtheone/Teleport
  10. Sending and syncing data • Activity (sending) or Service (receiving)

    • Data types: ◦ Messages mTeleportClient.sendMessage("/play/3333", null); ◦ DataItems mTeleportClient.syncString("/message-text", "Hello, World!"); ◦ Assets ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteStream); Asset asset = Asset.createFromBytes(byteStream.toByteArray()); mTeleportClient.syncAsset("/background", asset);