Android Wear Development

Fe087c5a0e898cd95c67973aa97f2067?s=47 David Vávra
September 05, 2014

Android Wear Development

Fe087c5a0e898cd95c67973aa97f2067?s=128

David Vávra

September 05, 2014
Tweet

Transcript

  1. Android Wear Development David Vávra Avast Mobile

  2. None
  3. None
  4. None
  5. 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
  6. Design vision vs

  7. Design principles Launched automatically Think about the stream first

  8. Design guidelines Glanceable Zero or low interaction

  9. Design principles Design for big gestures Do one thing really

    fast Don’t be a constant shoulder-tapper Don’t stop the user
  10. WearSquare

  11. Development: Two ways Extending notifications

  12. Development: Two ways Native apps

  13. 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();
  14. 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);
  15. 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();
  16. 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
  17. GridViewPager & FragmentGridPagerAdaper

  18. CardFragment & CircledImageView https://github.com/destil/WearSquare/blob/master/wear/src/main/java/cz/destil/wearsquare/fragment/ActionFragment.java

  19. WearableListView & DelayedConfirmationView

  20. ConfirmationActivity

  21. 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”
  22. 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
  23. 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
  24. 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);
  25. Example code https://github.com/destil/WearSquare

  26. What apps are great on watch:

  27. Q&A Documentation: • http://developer.android.com/design/wear • http://developer.android. com/training/building-wearables.html Follow me: •

    http://google.com/+DavidVávra • http://twitter.com/destil