SlideShare a Scribd company logo
1 of 28
Android Wear
developer’s perspective
Sebastian Vieira
S
Topics
Notifications
Native Apps
Watchfaces
What kind of apps?
Launched automatically “suggests”
Context Stream cards
Glanceable
See the content in a split second
All about suggest and demand
A personal assistant: it interrupts only when necessary
Zero or low interaction
User input only when necessary: touch, swipes, voice
What kind of apps?
Three ways to develop for Android Wear
Android notifications
Native android wear apps
Watchfaces
adb -d forward tcp:5601 tcp:5601
Notifications
It is standard notifications but…
You have to use NotificationCompat
NotificationCompat.WearableExtender
Helper class to add wearable extensions,
actions...
Notifications - Voice
We want to dictate to the watch
RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)...build()
NotificationCompat.Action.Builder(R.drawable.ic_reply_icon, getString(R.string.label), intent)
.addRemoteInput(remoteInput)
.build();
Your Android phone receives it:
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
CharSequence reply = remoteInput.getCharSequence(EXTRA_VOICE_REPLY);
Notifications - Voice
Predefined text responses
<string-array name="reply_choices">
<item>Yes</item>
<item>No</item>
<item>Maybe</item>
</string-array>
RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
.setLabel(replyLabel)
.setChoices(replyChoices)
.build();
Notifications - Pages
NotificationWearableExtender:
addPage(Notification notif)
// Create a big text style for the second page
BigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle();
secondPageStyle.setBigContentTitle("Page 2").bigText("A lot of text...");
// Create second page notification
Notification secondPageNotification = new NotificationCompat.Builder(this).setStyle(secondPageStyle).build();
// Extend the notification builder with the second page
Notification notification = notificationBuilder.extend(new NotificationCompat.WearableExtender()
.addPage(secondPageNotification)).build();
Notifications - Stacking
NotificationCompat.Builder(ctx)
setGroup(String key)
Important to add summary
setGroupSummary(true)
Wear Apps
Direct access to HW of the watch
Timeout period after which watch goes to sleep
Bundled within a bigger app
Access to all Android APIs except:
webkit, print, backup, appwidgets and usb
Wear App project
Notifications:
support library v4
Data Layer
Google Play Service
Wearable UI support library
Unofficial library (wtf?)
Wear App UI
BoxInsetLayout - A FrameLayout that's aware of screen shape
CardFragment - Vertically scrollable card.
CircledImageView
ConfirmationActivity - An activity that displays confirmation animations
CrossFadeDrawable
DelayedConfirmationView - Circular countdown timer
DismissOverlayView - Long-press-to-dismiss.
DotsPageIndicator - Page indicator for GridViewPager that identifies the current page
GridViewPager: GridPagerAdapter, FragmentGridPagerAdapter
WatchViewStub - A class that can inflate a specific layout, based on the device's screen.
WearableListView - An alternative version of ListView
Wear App UI
Since the library is not supported, it can change
(and it does break pretty badly)
https://developer.android.com/reference/android/support/wearable/view/package-summary.html
Voice
Voice is an important part of Android Wear
Two types of voice actions:
System provided
Task based build in the OS ("OK Google, what’s my bpm?")
App provided
App based (‘Start’+Activity Name)
Sytem Voice Actions
Taxi, notes, alarm, timer, bike, run, workout,
heart rate, step count
Action, Mime Type, Extras, Category in manifest
<activity android:name="MyNoteActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="com.google.android.voicesearch.SELF_NOTE" />
</intent-filter>
</activity>
Form free speech input
Speech Recogniser, useful for dictating text
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
startActivityForResult(intent, SPEECH_REQUEST_CODE);
…
if (requestCode == SPEECH_REQUEST_CODE && resultCode == RESULT_OK) {
List<String> results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
String spokenText = results.get(0);
}
Data layer API
To communicate with the watch:
Create an instance of GoogleApiClient
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(new ConnectionCallbacks() {...})
.addOnConnectionFailedListener(new OnConnectionFailedListener() {...})
// Request access only to the Wearable API
.addApi(Wearable.API)
.build();
Use one separate instance for Android Wear!
Data layer API
Data Items
Data storage with automatic syncing.
MessageApi
Good for remote procedure calls (RPC)
Fire and Forget commands
Asset
Sending binary blobs of data, such as images.
With caching for large assets (to avoid Bluetooth bandwith issues)
Data layer API
WearableListenerService (for services)
Listen for important data layer events in a service. The system manages
its lifecycle binding to the service when it needs to send data items or
messages and unbinding the service when no work is needed.
DataListener (for foreground activities)
Listen for important data layer events when an activity is in the
foreground. Using this instead of the WearableListenerService lets you
listen for changes only when the user is actively using your app.
Watch Faces
Plan for square and round devices
Support all display modes (ambient, interactive)
Support special screen technologies
Make sure indicators are visible
Integrate data like calendar requests or weather
Provide configuration options
Watch Faces
They are services… wait… what?
CanvasWatchFaceService
Equivalent to View class
CanvasWatchFaceService.Engine
onDraw and callbacks of time, properties,
configurations changes
Watch Faces - Drawing
Create a timer that invalidates the engine
(ambient mode has system timer with callback onTimerTick)
Engine.onVisibilityChanged()
Where you start the timer and update the time zone
Engine.onAmbientModeChanged
Time to disable antialiasing, for example
Engine.onDraw(Canvas canvas, Rect bounds)
… where the fun starts
Lets say we want to show the weather…
Create a class inside your CanvasWatchFaceService.Engine implementation that extends AsyncTask
and add the code to retrieve the data you’re interested in.
Engine.onVisibilityChanged(boolean visible)
This method initializes the timer when the watch face becomes visible
Quite a manual process
Watch Faces - Show Info
Watch Faces - Configuration
Create a Wearable Configuration Activity
Runs in the watch: do not make it too complex
Create a Companion Configuration Activity
This runs on the device within the Android Wear app - It can be as complex as you want
Create a Listener Service in the Wearable App
...because we have to sync configurations between device and watch
Use the WearableListenerService interface from the Wearable Data Layer API
The Watchface will redraw itself when the configuration changes
Thanks!
Sebastian Vieira
sebastian.vieira@local.ch
@seviu

More Related Content

Viewers also liked

The Voice Pick Code and Order Selection
The Voice Pick Code and Order SelectionThe Voice Pick Code and Order Selection
The Voice Pick Code and Order SelectionBoreal Technologies
 
Voice based email for blinds
Voice based email for blindsVoice based email for blinds
Voice based email for blindsArjun AJ
 
Schoevers hbo2 141113
Schoevers hbo2 141113Schoevers hbo2 141113
Schoevers hbo2 141113Erik Scarcia
 
Voice Mashups: Telephony power without telephony expertise
Voice Mashups:  Telephony power without telephony expertiseVoice Mashups:  Telephony power without telephony expertise
Voice Mashups: Telephony power without telephony expertiseVoodooLabs
 
Speech recognition project report
Speech recognition project reportSpeech recognition project report
Speech recognition project reportSarang Afle
 

Viewers also liked (6)

Hacking Blind
Hacking BlindHacking Blind
Hacking Blind
 
The Voice Pick Code and Order Selection
The Voice Pick Code and Order SelectionThe Voice Pick Code and Order Selection
The Voice Pick Code and Order Selection
 
Voice based email for blinds
Voice based email for blindsVoice based email for blinds
Voice based email for blinds
 
Schoevers hbo2 141113
Schoevers hbo2 141113Schoevers hbo2 141113
Schoevers hbo2 141113
 
Voice Mashups: Telephony power without telephony expertise
Voice Mashups:  Telephony power without telephony expertiseVoice Mashups:  Telephony power without telephony expertise
Voice Mashups: Telephony power without telephony expertise
 
Speech recognition project report
Speech recognition project reportSpeech recognition project report
Speech recognition project report
 

Similar to Develop Android Wear Apps

Android apps development
Android apps developmentAndroid apps development
Android apps developmentMonir Zzaman
 
Break Timer: Android-wear introduction and application case-study
Break Timer: Android-wear introduction and application case-studyBreak Timer: Android-wear introduction and application case-study
Break Timer: Android-wear introduction and application case-studyUmair Vatao
 
Android Tutorial
Android TutorialAndroid Tutorial
Android TutorialFun2Do Labs
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidDenis Minja
 
Android Evolution, AppForum 2014, Brussels, Friedger Müffke
Android Evolution, AppForum 2014, Brussels, Friedger MüffkeAndroid Evolution, AppForum 2014, Brussels, Friedger Müffke
Android Evolution, AppForum 2014, Brussels, Friedger MüffkeFriedger Müffke
 
Advance ui development and design
Advance ui  development and design Advance ui  development and design
Advance ui development and design Rakesh Jha
 
Android broadcast receiver tutorial
Android broadcast receiver   tutorialAndroid broadcast receiver   tutorial
Android broadcast receiver tutorialmaamir farooq
 
Android broadcast receiver tutorial
Android broadcast receiver  tutorialAndroid broadcast receiver  tutorial
Android broadcast receiver tutorialmaamir farooq
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updatedGhanaGTUG
 
Synapseindia android apps intro to android development
Synapseindia android apps  intro to android developmentSynapseindia android apps  intro to android development
Synapseindia android apps intro to android developmentSynapseindiappsdevelopment
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android AppsGil Irizarry
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2Vivek Bhusal
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureVijay Rastogi
 
Getting started with android dev and test perspective
Getting started with android   dev and test perspectiveGetting started with android   dev and test perspective
Getting started with android dev and test perspectiveGunjan Kumar
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basicsAnton Narusberg
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesAhsanul Karim
 

Similar to Develop Android Wear Apps (20)

Designing Apps for the Motorola XOOM
Designing Apps for the Motorola XOOM Designing Apps for the Motorola XOOM
Designing Apps for the Motorola XOOM
 
Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Break Timer: Android-wear introduction and application case-study
Break Timer: Android-wear introduction and application case-studyBreak Timer: Android-wear introduction and application case-study
Break Timer: Android-wear introduction and application case-study
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
Android Widget
Android WidgetAndroid Widget
Android Widget
 
App widget
App widgetApp widget
App widget
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
Android Evolution, AppForum 2014, Brussels, Friedger Müffke
Android Evolution, AppForum 2014, Brussels, Friedger MüffkeAndroid Evolution, AppForum 2014, Brussels, Friedger Müffke
Android Evolution, AppForum 2014, Brussels, Friedger Müffke
 
Advance ui development and design
Advance ui  development and design Advance ui  development and design
Advance ui development and design
 
Android 3
Android 3Android 3
Android 3
 
Android broadcast receiver tutorial
Android broadcast receiver   tutorialAndroid broadcast receiver   tutorial
Android broadcast receiver tutorial
 
Android broadcast receiver tutorial
Android broadcast receiver  tutorialAndroid broadcast receiver  tutorial
Android broadcast receiver tutorial
 
21 android2 updated
21 android2 updated21 android2 updated
21 android2 updated
 
Synapseindia android apps intro to android development
Synapseindia android apps  intro to android developmentSynapseindia android apps  intro to android development
Synapseindia android apps intro to android development
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structure
 
Getting started with android dev and test perspective
Getting started with android   dev and test perspectiveGetting started with android   dev and test perspective
Getting started with android dev and test perspective
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
 
Day 3: Getting Active Through Activities
Day 3: Getting Active Through ActivitiesDay 3: Getting Active Through Activities
Day 3: Getting Active Through Activities
 

Recently uploaded

ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 

Develop Android Wear Apps

  • 2.
  • 4. What kind of apps? Launched automatically “suggests” Context Stream cards Glanceable See the content in a split second All about suggest and demand A personal assistant: it interrupts only when necessary Zero or low interaction User input only when necessary: touch, swipes, voice
  • 5. What kind of apps? Three ways to develop for Android Wear Android notifications Native android wear apps Watchfaces
  • 6. adb -d forward tcp:5601 tcp:5601
  • 7. Notifications It is standard notifications but… You have to use NotificationCompat NotificationCompat.WearableExtender Helper class to add wearable extensions, actions...
  • 8. Notifications - Voice We want to dictate to the watch RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)...build() NotificationCompat.Action.Builder(R.drawable.ic_reply_icon, getString(R.string.label), intent) .addRemoteInput(remoteInput) .build(); Your Android phone receives it: Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); CharSequence reply = remoteInput.getCharSequence(EXTRA_VOICE_REPLY);
  • 9. Notifications - Voice Predefined text responses <string-array name="reply_choices"> <item>Yes</item> <item>No</item> <item>Maybe</item> </string-array> RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) .setLabel(replyLabel) .setChoices(replyChoices) .build();
  • 10. Notifications - Pages NotificationWearableExtender: addPage(Notification notif) // Create a big text style for the second page BigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle(); secondPageStyle.setBigContentTitle("Page 2").bigText("A lot of text..."); // Create second page notification Notification secondPageNotification = new NotificationCompat.Builder(this).setStyle(secondPageStyle).build(); // Extend the notification builder with the second page Notification notification = notificationBuilder.extend(new NotificationCompat.WearableExtender() .addPage(secondPageNotification)).build();
  • 11. Notifications - Stacking NotificationCompat.Builder(ctx) setGroup(String key) Important to add summary setGroupSummary(true)
  • 12.
  • 13. Wear Apps Direct access to HW of the watch Timeout period after which watch goes to sleep Bundled within a bigger app Access to all Android APIs except: webkit, print, backup, appwidgets and usb
  • 14. Wear App project Notifications: support library v4 Data Layer Google Play Service Wearable UI support library Unofficial library (wtf?)
  • 15. Wear App UI BoxInsetLayout - A FrameLayout that's aware of screen shape CardFragment - Vertically scrollable card. CircledImageView ConfirmationActivity - An activity that displays confirmation animations CrossFadeDrawable DelayedConfirmationView - Circular countdown timer DismissOverlayView - Long-press-to-dismiss. DotsPageIndicator - Page indicator for GridViewPager that identifies the current page GridViewPager: GridPagerAdapter, FragmentGridPagerAdapter WatchViewStub - A class that can inflate a specific layout, based on the device's screen. WearableListView - An alternative version of ListView
  • 16. Wear App UI Since the library is not supported, it can change (and it does break pretty badly) https://developer.android.com/reference/android/support/wearable/view/package-summary.html
  • 17. Voice Voice is an important part of Android Wear Two types of voice actions: System provided Task based build in the OS ("OK Google, what’s my bpm?") App provided App based (‘Start’+Activity Name)
  • 18. Sytem Voice Actions Taxi, notes, alarm, timer, bike, run, workout, heart rate, step count Action, Mime Type, Extras, Category in manifest <activity android:name="MyNoteActivity"> <intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="com.google.android.voicesearch.SELF_NOTE" /> </intent-filter> </activity>
  • 19. Form free speech input Speech Recogniser, useful for dictating text Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); startActivityForResult(intent, SPEECH_REQUEST_CODE); … if (requestCode == SPEECH_REQUEST_CODE && resultCode == RESULT_OK) { List<String> results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); String spokenText = results.get(0); }
  • 20. Data layer API To communicate with the watch: Create an instance of GoogleApiClient GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(new ConnectionCallbacks() {...}) .addOnConnectionFailedListener(new OnConnectionFailedListener() {...}) // Request access only to the Wearable API .addApi(Wearable.API) .build(); Use one separate instance for Android Wear!
  • 21. Data layer API Data Items Data storage with automatic syncing. MessageApi Good for remote procedure calls (RPC) Fire and Forget commands Asset Sending binary blobs of data, such as images. With caching for large assets (to avoid Bluetooth bandwith issues)
  • 22. Data layer API WearableListenerService (for services) Listen for important data layer events in a service. The system manages its lifecycle binding to the service when it needs to send data items or messages and unbinding the service when no work is needed. DataListener (for foreground activities) Listen for important data layer events when an activity is in the foreground. Using this instead of the WearableListenerService lets you listen for changes only when the user is actively using your app.
  • 23. Watch Faces Plan for square and round devices Support all display modes (ambient, interactive) Support special screen technologies Make sure indicators are visible Integrate data like calendar requests or weather Provide configuration options
  • 24. Watch Faces They are services… wait… what? CanvasWatchFaceService Equivalent to View class CanvasWatchFaceService.Engine onDraw and callbacks of time, properties, configurations changes
  • 25. Watch Faces - Drawing Create a timer that invalidates the engine (ambient mode has system timer with callback onTimerTick) Engine.onVisibilityChanged() Where you start the timer and update the time zone Engine.onAmbientModeChanged Time to disable antialiasing, for example Engine.onDraw(Canvas canvas, Rect bounds) … where the fun starts
  • 26. Lets say we want to show the weather… Create a class inside your CanvasWatchFaceService.Engine implementation that extends AsyncTask and add the code to retrieve the data you’re interested in. Engine.onVisibilityChanged(boolean visible) This method initializes the timer when the watch face becomes visible Quite a manual process Watch Faces - Show Info
  • 27. Watch Faces - Configuration Create a Wearable Configuration Activity Runs in the watch: do not make it too complex Create a Companion Configuration Activity This runs on the device within the Android Wear app - It can be as complex as you want Create a Listener Service in the Wearable App ...because we have to sync configurations between device and watch Use the WearableListenerService interface from the Wearable Data Layer API The Watchface will redraw itself when the configuration changes