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

Android Wear: from zero to hero

Android Wear: from zero to hero

Android Wear è ormai una realtà abbastanza diffusa e poterlo utilizzare al meglio può senz’altro dare una marcia in più alle nostre app: vedremo in questo workshop come integrare l’SDK di Android Wear, partendo innanzitutto dalle regole per lo sviluppo con Android Wear e dal setup della nostra postazione di lavoro, passando poi alla gestione delle notifiche ricche, la comunicazione con il dispositivo indossabile e la creazione di una semplice app che metta a frutto le tecnologie che abbiamo appreso, cercando di sfruttare al massimo le potenzialità che Google ci ha fornito.

Roberto Orgiu

November 20, 2015
Tweet

More Decks by Roberto Orgiu

Other Decks in Technology

Transcript

  1. What’s new in Android Wear • API 23 • Emulator

    • Permission model • AudioTrack, MediaPlayer and ExoPlayer • -round and -notround resource qualifiers • Intel x86 support
  2. The Wear Playlist • Setting up the environment • Download

    the base project • Working with Notifications • Custom stuff • Sync all the data!
  3. Setting up the environment • Start the Wear emulator •

    Enable ADB debug • Connect your phone to the USB • Run the adb -d forward tcp:5601 tcp:5601 command • Pair with the Wear Emulator
  4. The Wear Playlist • Setting up the environment • Download

    the base project • Working with Notifications • Custom stuff • Sync all the data!
  5. The Wear Playlist • Setting up the environment • Download

    the base project • Working with Notifications • Custom stuff • Sync all the data!
  6. Working with Notifications Big Views BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();

    bigStyle.bigText(eventDescription); new NotificationCompat.Builder(this) NotificationCompat.Builder notificationBuilder = .setStyle(bigStyle); http://goo.gl/GLhd78
  7. Working with Notifications Wear specific actions BigTextStyle bigStyle = new

    NotificationCompat.BigTextStyle(); bigStyle.bigText(eventDescription); new NotificationCompat.Builder(this) NotificationCompat.Builder notificationBuilder = .setStyle(bigStyle); http://goo.gl/GLhd78 .extend(new WearableExtender().addAction(action)) // Big Views
  8. Working with Notifications ~ 30 minutes BigTextStyle bigStyle = new

    NotificationCompat.BigTextStyle(); bigStyle.bigText(eventDescription); new NotificationCompat.Builder(this) NotificationCompat.Builder notificationBuilder = .setStyle(bigStyle); http://goo.gl/GLhd78 .extend(new WearableExtender() .addAction(action)) // Big Views // Wear specific actions
  9. The Wear Playlist • Setting up the environment • Download

    the base project • Working with Notifications • Custom stuff • Sync all the data!
  10. Custom stuff Custom layouts • BoxInsetLayout • CardFragment • CircledImageView

    • ConfirmationActivity • CrossfadeActivity • DelayedConfirmationView • DismissOverlayView • GridViewPager • GridPagerAdapter • FragmentGridPagerAdapter • DotSpaceIndicator • WatchViewStub • WearableListView http://goo.gl/JYGOkO
  11. • Extend WearableActivity • Call setAmbientEnabled() • Override onEnterAmbient(Bundle ambientDetails)

    • Override onExitAmbient() • Don’t forget onUpdateAmbient() Custom stuff Keeping your app visible http://goo.gl/D7oixw
  12. The Wear Playlist • Setting up the environment • Download

    the base project • Working with Notifications • Custom stuff • Sync all the data!
  13. Sync all the data! • Access the data layer •

    Choose the right way to communicate • Implement the listener
  14. Sync all the data! • Declare Google API Client on

    both the phone and the wearable project • Invoke connect() method • Start using the client in the onConnected() callback • Module /communication in the sample project Access the data layer
  15. Sync all the data! • Access the data layer •

    Choose the right way to communicate • Implement the listener
  16. Sync all the data! • DataItem - automatic sync •

    MessageApi - remote procedure calls • Asset - blobs of data • WearableListenerService - background services • DataListener and MessageListener - foreground components • ChannelApi - Assets sync’ed with DataItems, good for large files Choose the right way to communicate http://goo.gl/x8t3YG
  17. Sync all the data! • DataItem - automatic sync •

    MessageApi - remote procedure calls • Asset - blobs of data • WearableListenerService - background services • DataListener and MessageListener - foreground components • ChannelApi - Assets sync’ed with DataItems, good for large files Choose the right way to communicate http://goo.gl/x8t3YG
  18. Sync all the data! MessageApi and MessageListener • Find connected

    nodes with NodeApi.getConnectedNodes() • Implement MessageListener • Set the listener with MessageApi.addListener() • Send message with MessageApi.sendMessage() http://goo.gl/B5rCMZ ~45 minutes