android wear from zero to hero

29
from zero to hero

Upload: roberto-orgiu

Post on 12-Apr-2017

372 views

Category:

Mobile


1 download

TRANSCRIPT

Page 1: Android Wear from zero to hero

from zero to hero

Page 2: Android Wear from zero to hero

About meAndroid Developer

Tech enthusiast

Writer

RxJava addict

Kotlin curious

Page 3: Android Wear from zero to hero

What’s new in Android Wear

• API 23 • Emulator • Permission model • AudioTrack, MediaPlayer and ExoPlayer

• -round and -notround resource qualifiers • Intel x86 support

Page 4: Android Wear from zero to hero

The Wear Playlist

• Setting up the environment

• Download the base project

• Working with Notifications

• Custom stuff

• Sync all the data!

Page 5: Android Wear from zero to hero

Setting up the environment

Install the Android Wear SDK from the SDK Manager

Page 6: Android Wear from zero to hero

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

Page 7: Android Wear from zero to hero

The Wear Playlist

• Setting up the environment

• Download the base project

• Working with Notifications

• Custom stuff

• Sync all the data!

Page 8: Android Wear from zero to hero

Download the base project

https://goo.gl/IAGVSJ

Page 9: Android Wear from zero to hero

The Wear Playlist

• Setting up the environment

• Download the base project

• Working with Notifications

• Custom stuff

• Sync all the data!

Page 10: Android Wear from zero to hero

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

Page 11: Android Wear from zero to hero

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

Page 12: Android Wear from zero to hero

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

Page 13: Android Wear from zero to hero

The Wear Playlist

• Setting up the environment

• Download the base project

• Working with Notifications

• Custom stuff

• Sync all the data!

Page 14: Android Wear from zero to hero

Custom stuff

• Custom notifications

• Custom layouts

• Keeping your app visible

Page 15: Android Wear from zero to hero

Custom stuffCustom notifications

• Created on Wear

• Not synchronised on the paired device

Page 16: Android Wear from zero to hero

Custom stuff

• Custom notifications

• Custom layouts

• Keeping your app visible

Page 17: Android Wear from zero to hero

Custom stuffCustom layouts

• BoxInsetLayout • CardFragment • CircledImageView • ConfirmationActivity • CrossfadeActivity • DelayedConfirmationView • DismissOverlayView • GridViewPager • GridPagerAdapter • FragmentGridPagerAdapter • DotSpaceIndicator • WatchViewStub • WearableListView

http://goo.gl/JYGOkO

Page 18: Android Wear from zero to hero

Custom stuff

• Custom notifications

• Custom layouts

• Keeping your app visible

Page 19: Android Wear from zero to hero

• Extend WearableActivity

• Call setAmbientEnabled()

• Override onEnterAmbient(Bundle ambientDetails)

• Override onExitAmbient()

• Don’t forget onUpdateAmbient()

Custom stuffKeeping your app visible

http://goo.gl/D7oixw

Page 20: Android Wear from zero to hero

Custom stuff

• Custom notifications

• Custom layouts

• Keeping your app visible

Page 21: Android Wear from zero to hero

Custom stuff

goo.gl/D7oixwgoo.gl/JYGOkO

Code time!~45 minutes

Page 22: Android Wear from zero to hero

The Wear Playlist

• Setting up the environment

• Download the base project

• Working with Notifications

• Custom stuff

• Sync all the data!

Page 23: Android Wear from zero to hero

Sync all the data!

• Access the data layer

• Choose the right way to communicate

• Implement the listener

Page 24: Android Wear from zero to hero

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

Page 25: Android Wear from zero to hero

Sync all the data!

• Access the data layer

• Choose the right way to communicate

• Implement the listener

Page 26: Android Wear from zero to hero

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

Page 27: Android Wear from zero to hero

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

Page 28: Android Wear from zero to hero

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

Page 29: Android Wear from zero to hero

Thanks

@_tiwiz