Android Wear from zero to hero

Post on 12-Apr-2017

372 views 1 download

Transcript of Android Wear from zero to hero

from zero to hero

About meAndroid Developer

Tech enthusiast

Writer

RxJava addict

Kotlin curious

What’s new in Android Wear

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

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

The Wear Playlist

• Setting up the environment

• Download the base project

• Working with Notifications

• Custom stuff

• Sync all the data!

Setting up the environment

Install the Android Wear SDK from the SDK Manager

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

The Wear Playlist

• Setting up the environment

• Download the base project

• Working with Notifications

• Custom stuff

• Sync all the data!

Download the base project

https://goo.gl/IAGVSJ

The Wear Playlist

• Setting up the environment

• Download the base project

• Working with Notifications

• Custom stuff

• Sync all the data!

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

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

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

The Wear Playlist

• Setting up the environment

• Download the base project

• Working with Notifications

• Custom stuff

• Sync all the data!

Custom stuff

• Custom notifications

• Custom layouts

• Keeping your app visible

Custom stuffCustom notifications

• Created on Wear

• Not synchronised on the paired device

Custom stuff

• Custom notifications

• Custom layouts

• Keeping your app visible

Custom stuffCustom layouts

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

http://goo.gl/JYGOkO

Custom stuff

• Custom notifications

• Custom layouts

• Keeping your app visible

• Extend WearableActivity

• Call setAmbientEnabled()

• Override onEnterAmbient(Bundle ambientDetails)

• Override onExitAmbient()

• Don’t forget onUpdateAmbient()

Custom stuffKeeping your app visible

http://goo.gl/D7oixw

Custom stuff

• Custom notifications

• Custom layouts

• Keeping your app visible

Custom stuff

goo.gl/D7oixwgoo.gl/JYGOkO

Code time!~45 minutes

The Wear Playlist

• Setting up the environment

• Download the base project

• Working with Notifications

• Custom stuff

• Sync all the data!

Sync all the data!

• Access the data layer

• Choose the right way to communicate

• Implement the listener

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

Sync all the data!

• Access the data layer

• Choose the right way to communicate

• Implement the listener

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

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

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

Thanks

@_tiwiz