SlideShare ist ein Scribd-Unternehmen logo
1 von 74
Android Wear: A Developer’s 
Perspective 
Marc Lester Tan 
Mobility Innovation Center, APJ 
w: marctan.com 
t: @mharkus 
+MarcLesterTan
Agenda 
• Introduction to Android Wear 
• Notifications 
• Wearable Apps 
• Watch Faces 
• Demo
Notifications
Simple Notification 
PendingIntent pendingIntent = createIntent(); 
NotificationCompat.Builder builder = new NotificationCompat.Builder(this) 
.setContentTitle(“Message from Weng”) 
.setContentText(“Don’t forget to try Penang Laksa!”) 
.setSmallIcon(R.drawable.ic_launcher) 
.setContentIntent(pendingIntent); 
notificationMgr = NotificationManagerCompat.from(this); 
notificationMgr.notify(0, builder.build());
NO WORK 
REQUIRED
Stacks Pages Replies
Stacked 
Notifications
Stacked Notifications 
builder1 = createNotification(“Don’t forget to try Penang Laksa!”); 
builder1.setGroup("MESSAGES_GROUP_KEY”); 
builder2 = createNotification(“Also their Char Koay Teow!”); 
builder2.setGroup("MESSAGES_GROUP_KEY”); 
summary = createNotification(“2 Messages from Weng”); 
summary.setGroup(”MESSAGES_GROUP_KEY”); 
summary.setGroupSummary(true); 
notificationMgr.notify(0, builder1.build()); 
notificationMgr.notify(1, builder2.build()); 
notificationMgr.notify(2, summary.build());
Pages
Pages 
NotificationCompat.BigPictureStyle style = new 
NotificationCompat.BigPictureStyle(); 
style.setBigContentTitle(”Penang Laksa"); 
pageNotif = NotificationCompat.Builder(this) 
.setStyle(style) 
.setContentText("Mouth Watering!") 
.extend(new NotificationCompat.WearableExtender() 
.setBackground(penangLaksaBitmap) 
.build();
Pages 
builder1 = createNotification(“Don’t forget to try Penang Laksa!”); 
wearableExtender = 
new NotificationCompat.WearableExtender() 
.setHintHideIcon(true) 
.setBackground(mainbgBitmap) 
.addPage(pageNotif); 
builder1.extend(wearableExtender); 
notificationMgr.notify(0, builder1.build());
Replies
Replies 
• RemoteInput remoteInput = new 
RemoteInput.Builder("extra_voice_reply”) 
.setLabel("What do you think?") 
.setChoices(new String[]{ 
"Awesome", 
"Shiok!", 
"Nom nom nom!" 
}) 
.build();
Replies 
Action action = new Action.Builder(replyIcon,"Reply”, 
replyPendingIntent) 
.addRemoteInput(remoteInput) 
.build(); 
builder1 = createNotification(“Don’t forget to try Penang Laksa!”); 
builder1.extend(wearableExtender.addAction(action)); 
notificationMgr.notify(0, builder1.build());
Receiving Voice Input 
Bundle remoteInput = RemoteInput.getResultsFromIntent(getIntent()); 
if (remoteInput != null) { 
reply = remoteInput.getCharSequence("extra_voice_reply”); 
}
Wearable Apps
Wearable Apps 
• Run directly on the device 
• Access to sensors and GPU 
• Greatly differ in design and usability 
• Limited functionality
Wearable vs Handheld Apps 
• System enforces timeout period 
• Relatively small in size and functionality 
• Users don’t download apps directly to wearable 
• Don’t support the following APIs 
• android.webkit 
• android.print 
• android.app.backup 
• android.appwidget 
• android.hardware.usb
Creating Wearable 
Apps
Creating Wearable Apps
Creating Wearable Apps
Creating Wearable Apps
Creating Wearable Apps
Creating Wearable Apps
Creating Wearable Apps
Creating Wearable Apps
Data Exchange Custom UI Voice Actions
Data Exchange 
Node 
Message 
Data
Create a GoogleApiClient 
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this) 
.addConnectionCallbacks(new ConnectionCallbacks() { 
public void onConnected(Bundle connectionHint) { 
// Now you can use the data layer API 
} 
... 
}) 
.addOnConnectionFailedListener(new OnConnectionFailedListener() { 
public void onConnectionFailed(ConnectionResult result) { 
} 
}) 
// Request access only to the Wearable API 
.addApi(Wearable.API) 
.build(); 
mGoogleApiClient.connect();
Check for connected nodes 
nodes = Wearable.NodeApi 
.getConnectedNodes(mGoogleApiClient) 
.await(); 
nodeList = nodes.getNodes(); 
if (nodeList.size() > 0) { 
connectedNode = nodeList.get(0); 
}
Send a message 
result = Wearable.MessageApi 
.sendMessage(mGoogleApiClient, parentNode.getId(), "/start/MainActivity/", 
message.getBytes()); 
result.setResultCallback(new 
ResultCallback<MessageApi.SendMessageResult>() { 
public void onResult(MessageApi.SendMessageResult 
sendMessageResult) { 
if (!sendMessageResult.getStatus().isSuccess()) { 
// handle error 
} 
} 
});
Receive a message 
@Override 
public void onMessageReceived(MessageEvent messageEvent) { 
String message = new String(messageEvent.getData()); 
}
Send a data 
map = PutDataMapRequest.create("/image"); 
map.getDataMap().putAsset("image”,assetFromBitmap); 
PutDataRequest request = map.asPutDataRequest(); 
pendingResult = Wearable.DataApi 
.putDataItem(mGoogleApiClient,request);
Receive a data 
@Override 
public void onDataChanged(DataEventBuffer dataEvents) { 
for (DataEvent event : dataEvents) { 
if (event.getType() == DataEvent.TYPE_CHANGED && 
event.getDataItem() 
.getUri().getPath() 
.equals("/image")) { 
dataMapItem = DataMapItem 
.fromDataItem(event.getDataItem()); 
profileAsset = dataMapItem.getDataMap() 
.getAsset("image"); 
} 
} 
}
public class MyWearListener extends WearableListenerService { 
@Override 
public void onMessageReceived(MessageEvent messageEvent) { 
} 
@Override 
public void onDataChanged(DataEventBuffer dataEvents) { 
} 
@Override 
public void onPeerConnected(Node peer) { 
} 
@Override 
public void onPeerDisconnected(Node peer) { 
} 
}
Intent Filter 
<service android:name=”.MyWearListener" > 
<intent-filter> 
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" /> 
</intent-filter> 
</service>
Custom 
Layouts
● BoxInsetLayout 
● Card Fragment 
● CircledImageView 
● ConfirmationActivity 
● DismissOverlayView 
● DelayedConfirmationView 
● GridViewPager 
● GridPagerAdapter 
● FragmentGridPagerAdapter 
● WatchViewStub
WatchViewStub 
<?xml version="1.0" encoding="utf-8"?> 
<android.support.wearable.view.WatchViewStub 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools=http://schemas.android.com/tools 
app:rectLayout="@layout/rect_activity_main" 
app:roundLayout="@layout/round_activity_main" 
tools:context=".Main" 
tools:deviceIds="wear" android:padding="12dp"> 
</android.support.wearable.view.WatchViewStub>
BoxInsetLayout
DelayedConfirmationView & 
ConfirmationActivity
CardFragment
Voice Actions
System Provided Action 
<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>
● Call a car/taxi 
● Take a note 
● Set alarm 
● Set timer 
● Start/Stop a bike ride 
● Start/Stop a run 
● Start/Stop a workout 
● Show heart rate 
● Show step count
App Provided Voice Action 
<activity android:name="StartRunActivity" 
android:label="MyRunningApp"> 
<intent-filter> 
<action android:name="android.intent.action.MAIN" /> 
<category 
android:name="android.intent.category.LAUNCHER" /> 
</intent-filter> 
</activity>
private void displaySpeechRecognizer() { 
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); 
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, 
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); 
startActivityForResult(intent, SPEECH_REQUEST_CODE); 
} 
Speech Recognizer
Watch Faces
UNOFFICIAL
Create a Wear Watch Face 
• Same steps as creating a wearable app 
• Uses Executors for per-second updates 
• Uses Intent.ACTION_TIME_TICK for per-minute 
updates 
• Use DisplayManager for screen events 
• HACK!
Create a Wear Watch Face
<activity 
android:name="com.marctan.hellowatchface.MainActivity" 
android:label="@string/app_name" 
android:allowEmbedded="true"> 
<meta-data 
android:name="com.google.android.clockwork.home.preview" 
android:resource="@drawable/ic_launcher" /> 
<intent-filter> 
<action android:name="android.intent.action.MAIN" /> 
<category 
android:name="com.google.android.clockwork.home.category.HOME_BACKGROUND" /> 
</intent-filter> 
. . . 
</activity> 
Modify AndroidManifest.xml
public void onDisplayAdded(int i) { 
} 
public void onDisplayRemoved(int i) { 
} 
public void onDisplayChanged(int displayId) { 
switch(displayManager.getDisplay(displayId).getState()){ 
case Display.STATE_OFF: 
case Display.STATE_DOZING: 
updateEveryMinute(); 
break; 
default: 
updateEverySecond(); 
break; 
} 
} 
DisplayListener Events
private void updateEverySecond() { 
. . . 
scheduledFuture = scheduleTaskExecutor.scheduleAtFixedRate(new 
Runnable() { 
public void run() { 
updateClockView(); 
} 
}, 0, 1, TimeUnit.SECONDS); 
} 
Per-second updates
private void updateEveryMinute() { 
if (scheduledFuture != null) { 
scheduledFuture.cancel(true); 
} 
ClockManager.getInstance().setAmbientMode(true); 
} 
Per-minute updates
Hello Wear Watch Face
Demo
Thank You 
Source Code 
github.com/mharkus/DevfestGeorgeTown2014 
Android Wear Dev Documentation 
developer.android.com/wear/index.html 
My Blog 
marctan.com
Android Wear: A Developer’s 
Perspective
Android Wear: A Developer’s 
Perspective

Weitere ähnliche Inhalte

Was ist angesagt?

Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Mahmoud Hamed Mahmoud
 
Getting your app ready for android n
Getting your app ready for android nGetting your app ready for android n
Getting your app ready for android nSercan Yusuf
 
Android N Highligts
Android N HighligtsAndroid N Highligts
Android N HighligtsSercan Yusuf
 
Developing for android wear
Developing for android wearDeveloping for android wear
Developing for android wearThomas Oldervoll
 
Google Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification GoogleGoogle Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification GoogleMathias Seguy
 
Academy PRO: HTML5 API multimedia
Academy PRO: HTML5 API multimediaAcademy PRO: HTML5 API multimedia
Academy PRO: HTML5 API multimediaBinary Studio
 
Android accessibility for developers and QA
Android accessibility for developers and QAAndroid accessibility for developers and QA
Android accessibility for developers and QATed Drake
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android AppsGil Irizarry
 
Azure mobile apps
Azure mobile appsAzure mobile apps
Azure mobile appsDavid Giard
 
Android Accessibility - The missing manual
Android Accessibility - The missing manualAndroid Accessibility - The missing manual
Android Accessibility - The missing manualTed Drake
 
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014Gil Irizarry
 
Riacon swiz
Riacon swizRiacon swiz
Riacon swizntunney
 
Meteor.js Workshop by Dopravo
Meteor.js Workshop by DopravoMeteor.js Workshop by Dopravo
Meteor.js Workshop by DopravoArabNet ME
 
Building a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web ServicesBuilding a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web ServicesDavid Giard
 
The Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, PepperThe Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, PepperDroidConTLV
 
Обзор Android M
Обзор Android MОбзор Android M
Обзор Android MWOX APP
 

Was ist angesagt? (18)

Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
 
Getting your app ready for android n
Getting your app ready for android nGetting your app ready for android n
Getting your app ready for android n
 
Android N Highligts
Android N HighligtsAndroid N Highligts
Android N Highligts
 
Developing for android wear
Developing for android wearDeveloping for android wear
Developing for android wear
 
Google Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification GoogleGoogle Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification Google
 
Activity
ActivityActivity
Activity
 
Academy PRO: HTML5 API multimedia
Academy PRO: HTML5 API multimediaAcademy PRO: HTML5 API multimedia
Academy PRO: HTML5 API multimedia
 
Android accessibility for developers and QA
Android accessibility for developers and QAAndroid accessibility for developers and QA
Android accessibility for developers and QA
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Azure mobile apps
Azure mobile appsAzure mobile apps
Azure mobile apps
 
Android Accessibility - The missing manual
Android Accessibility - The missing manualAndroid Accessibility - The missing manual
Android Accessibility - The missing manual
 
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
 
Riacon swiz
Riacon swizRiacon swiz
Riacon swiz
 
Meteor.js Workshop by Dopravo
Meteor.js Workshop by DopravoMeteor.js Workshop by Dopravo
Meteor.js Workshop by Dopravo
 
Building a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web ServicesBuilding a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web Services
 
Android Oreo
Android OreoAndroid Oreo
Android Oreo
 
The Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, PepperThe Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, Pepper
 
Обзор Android M
Обзор Android MОбзор Android M
Обзор Android M
 

Andere mochten auch

Andere mochten auch (6)

Google Dev Fest Presentation
Google Dev Fest PresentationGoogle Dev Fest Presentation
Google Dev Fest Presentation
 
Como evitar enfermarse
Como evitar enfermarseComo evitar enfermarse
Como evitar enfermarse
 
Como evitar enfermarse
Como evitar enfermarseComo evitar enfermarse
Como evitar enfermarse
 
Como evitar enfermarse
Como evitar enfermarseComo evitar enfermarse
Como evitar enfermarse
 
Como evitar enfermarse
Como evitar enfermarseComo evitar enfermarse
Como evitar enfermarse
 
Como evitar enfermarse
Como evitar enfermarseComo evitar enfermarse
Como evitar enfermarse
 

Ähnlich wie GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspective

Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Alfredo Morresi
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basicsAnton Narusberg
 
Getting Ready For Android Wear
Getting Ready For Android WearGetting Ready For Android Wear
Getting Ready For Android WearRaveesh Bhalla
 
android level 3
android level 3android level 3
android level 3DevMix
 
Android wear and Cardboard
Android wear and CardboardAndroid wear and Cardboard
Android wear and Cardboardmharkus
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android WearPeter Friese
 
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...Frédéric Harper
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CNjojule
 
Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 seriesopenbala
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recieversUtkarsh Mankad
 
Android studio
Android studioAndroid studio
Android studioAndri Yabu
 
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
 
What's New in Android
What's New in AndroidWhat's New in Android
What's New in AndroidRobert Cooper
 
Design Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesDesign Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesMichael Galpin
 
Android Quiz App – Test Your IQ.pdf
Android Quiz App – Test Your IQ.pdfAndroid Quiz App – Test Your IQ.pdf
Android Quiz App – Test Your IQ.pdfSudhanshiBakre1
 
Hieu Xamarin iOS9, Android M 3-11-2015
Hieu Xamarin iOS9, Android M  3-11-2015Hieu Xamarin iOS9, Android M  3-11-2015
Hieu Xamarin iOS9, Android M 3-11-2015Nguyen Hieu
 

Ähnlich wie GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspective (20)

Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
 
Getting Ready For Android Wear
Getting Ready For Android WearGetting Ready For Android Wear
Getting Ready For Android Wear
 
android level 3
android level 3android level 3
android level 3
 
Android Froyo
Android FroyoAndroid Froyo
Android Froyo
 
Android Wear Development
Android Wear DevelopmentAndroid Wear Development
Android Wear Development
 
Android wear and Cardboard
Android wear and CardboardAndroid wear and Cardboard
Android wear and Cardboard
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
 
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CN
 
Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 series
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
 
Android studio
Android studioAndroid studio
Android studio
 
Android 3
Android 3Android 3
Android 3
 
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
 
What's New in Android
What's New in AndroidWhat's New in Android
What's New in Android
 
Design Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesDesign Patterns for Tablets and Smartphones
Design Patterns for Tablets and Smartphones
 
Android Quiz App – Test Your IQ.pdf
Android Quiz App – Test Your IQ.pdfAndroid Quiz App – Test Your IQ.pdf
Android Quiz App – Test Your IQ.pdf
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
Hieu Xamarin iOS9, Android M 3-11-2015
Hieu Xamarin iOS9, Android M  3-11-2015Hieu Xamarin iOS9, Android M  3-11-2015
Hieu Xamarin iOS9, Android M 3-11-2015
 

Kürzlich hochgeladen

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 

Kürzlich hochgeladen (20)

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 

GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspective

  • 1. Android Wear: A Developer’s Perspective Marc Lester Tan Mobility Innovation Center, APJ w: marctan.com t: @mharkus +MarcLesterTan
  • 2. Agenda • Introduction to Android Wear • Notifications • Wearable Apps • Watch Faces • Demo
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 9. Simple Notification PendingIntent pendingIntent = createIntent(); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setContentTitle(“Message from Weng”) .setContentText(“Don’t forget to try Penang Laksa!”) .setSmallIcon(R.drawable.ic_launcher) .setContentIntent(pendingIntent); notificationMgr = NotificationManagerCompat.from(this); notificationMgr.notify(0, builder.build());
  • 10.
  • 11.
  • 15. Stacked Notifications builder1 = createNotification(“Don’t forget to try Penang Laksa!”); builder1.setGroup("MESSAGES_GROUP_KEY”); builder2 = createNotification(“Also their Char Koay Teow!”); builder2.setGroup("MESSAGES_GROUP_KEY”); summary = createNotification(“2 Messages from Weng”); summary.setGroup(”MESSAGES_GROUP_KEY”); summary.setGroupSummary(true); notificationMgr.notify(0, builder1.build()); notificationMgr.notify(1, builder2.build()); notificationMgr.notify(2, summary.build());
  • 16.
  • 17. Pages
  • 18. Pages NotificationCompat.BigPictureStyle style = new NotificationCompat.BigPictureStyle(); style.setBigContentTitle(”Penang Laksa"); pageNotif = NotificationCompat.Builder(this) .setStyle(style) .setContentText("Mouth Watering!") .extend(new NotificationCompat.WearableExtender() .setBackground(penangLaksaBitmap) .build();
  • 19. Pages builder1 = createNotification(“Don’t forget to try Penang Laksa!”); wearableExtender = new NotificationCompat.WearableExtender() .setHintHideIcon(true) .setBackground(mainbgBitmap) .addPage(pageNotif); builder1.extend(wearableExtender); notificationMgr.notify(0, builder1.build());
  • 20.
  • 22. Replies • RemoteInput remoteInput = new RemoteInput.Builder("extra_voice_reply”) .setLabel("What do you think?") .setChoices(new String[]{ "Awesome", "Shiok!", "Nom nom nom!" }) .build();
  • 23. Replies Action action = new Action.Builder(replyIcon,"Reply”, replyPendingIntent) .addRemoteInput(remoteInput) .build(); builder1 = createNotification(“Don’t forget to try Penang Laksa!”); builder1.extend(wearableExtender.addAction(action)); notificationMgr.notify(0, builder1.build());
  • 24.
  • 25. Receiving Voice Input Bundle remoteInput = RemoteInput.getResultsFromIntent(getIntent()); if (remoteInput != null) { reply = remoteInput.getCharSequence("extra_voice_reply”); }
  • 27. Wearable Apps • Run directly on the device • Access to sensors and GPU • Greatly differ in design and usability • Limited functionality
  • 28. Wearable vs Handheld Apps • System enforces timeout period • Relatively small in size and functionality • Users don’t download apps directly to wearable • Don’t support the following APIs • android.webkit • android.print • android.app.backup • android.appwidget • android.hardware.usb
  • 37. Data Exchange Custom UI Voice Actions
  • 38.
  • 39. Data Exchange Node Message Data
  • 40. Create a GoogleApiClient GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(new ConnectionCallbacks() { public void onConnected(Bundle connectionHint) { // Now you can use the data layer API } ... }) .addOnConnectionFailedListener(new OnConnectionFailedListener() { public void onConnectionFailed(ConnectionResult result) { } }) // Request access only to the Wearable API .addApi(Wearable.API) .build(); mGoogleApiClient.connect();
  • 41. Check for connected nodes nodes = Wearable.NodeApi .getConnectedNodes(mGoogleApiClient) .await(); nodeList = nodes.getNodes(); if (nodeList.size() > 0) { connectedNode = nodeList.get(0); }
  • 42. Send a message result = Wearable.MessageApi .sendMessage(mGoogleApiClient, parentNode.getId(), "/start/MainActivity/", message.getBytes()); result.setResultCallback(new ResultCallback<MessageApi.SendMessageResult>() { public void onResult(MessageApi.SendMessageResult sendMessageResult) { if (!sendMessageResult.getStatus().isSuccess()) { // handle error } } });
  • 43. Receive a message @Override public void onMessageReceived(MessageEvent messageEvent) { String message = new String(messageEvent.getData()); }
  • 44. Send a data map = PutDataMapRequest.create("/image"); map.getDataMap().putAsset("image”,assetFromBitmap); PutDataRequest request = map.asPutDataRequest(); pendingResult = Wearable.DataApi .putDataItem(mGoogleApiClient,request);
  • 45. Receive a data @Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED && event.getDataItem() .getUri().getPath() .equals("/image")) { dataMapItem = DataMapItem .fromDataItem(event.getDataItem()); profileAsset = dataMapItem.getDataMap() .getAsset("image"); } } }
  • 46. public class MyWearListener extends WearableListenerService { @Override public void onMessageReceived(MessageEvent messageEvent) { } @Override public void onDataChanged(DataEventBuffer dataEvents) { } @Override public void onPeerConnected(Node peer) { } @Override public void onPeerDisconnected(Node peer) { } }
  • 47. Intent Filter <service android:name=”.MyWearListener" > <intent-filter> <action android:name="com.google.android.gms.wearable.BIND_LISTENER" /> </intent-filter> </service>
  • 49.
  • 50. ● BoxInsetLayout ● Card Fragment ● CircledImageView ● ConfirmationActivity ● DismissOverlayView ● DelayedConfirmationView ● GridViewPager ● GridPagerAdapter ● FragmentGridPagerAdapter ● WatchViewStub
  • 51. WatchViewStub <?xml version="1.0" encoding="utf-8"?> <android.support.wearable.view.WatchViewStub xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools=http://schemas.android.com/tools app:rectLayout="@layout/rect_activity_main" app:roundLayout="@layout/round_activity_main" tools:context=".Main" tools:deviceIds="wear" android:padding="12dp"> </android.support.wearable.view.WatchViewStub>
  • 56.
  • 57. System Provided Action <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>
  • 58. ● Call a car/taxi ● Take a note ● Set alarm ● Set timer ● Start/Stop a bike ride ● Start/Stop a run ● Start/Stop a workout ● Show heart rate ● Show step count
  • 59. App Provided Voice Action <activity android:name="StartRunActivity" android:label="MyRunningApp"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
  • 60. private void displaySpeechRecognizer() { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); startActivityForResult(intent, SPEECH_REQUEST_CODE); } Speech Recognizer
  • 62.
  • 64. Create a Wear Watch Face • Same steps as creating a wearable app • Uses Executors for per-second updates • Uses Intent.ACTION_TIME_TICK for per-minute updates • Use DisplayManager for screen events • HACK!
  • 65. Create a Wear Watch Face
  • 66. <activity android:name="com.marctan.hellowatchface.MainActivity" android:label="@string/app_name" android:allowEmbedded="true"> <meta-data android:name="com.google.android.clockwork.home.preview" android:resource="@drawable/ic_launcher" /> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="com.google.android.clockwork.home.category.HOME_BACKGROUND" /> </intent-filter> . . . </activity> Modify AndroidManifest.xml
  • 67. public void onDisplayAdded(int i) { } public void onDisplayRemoved(int i) { } public void onDisplayChanged(int displayId) { switch(displayManager.getDisplay(displayId).getState()){ case Display.STATE_OFF: case Display.STATE_DOZING: updateEveryMinute(); break; default: updateEverySecond(); break; } } DisplayListener Events
  • 68. private void updateEverySecond() { . . . scheduledFuture = scheduleTaskExecutor.scheduleAtFixedRate(new Runnable() { public void run() { updateClockView(); } }, 0, 1, TimeUnit.SECONDS); } Per-second updates
  • 69. private void updateEveryMinute() { if (scheduledFuture != null) { scheduledFuture.cancel(true); } ClockManager.getInstance().setAmbientMode(true); } Per-minute updates
  • 71. Demo
  • 72. Thank You Source Code github.com/mharkus/DevfestGeorgeTown2014 Android Wear Dev Documentation developer.android.com/wear/index.html My Blog marctan.com
  • 73. Android Wear: A Developer’s Perspective
  • 74. Android Wear: A Developer’s Perspective

Hinweis der Redaktion

  1. Introduction to Android Wear Present the problem that Android Wear is trying to solve Short introduction as to what Android wear is Hello, Hello! Notifications Notifications from existing apps Customization of notifications specifically for Android Wear Stacks Pages Replies Wearable Apps Creating Wearable App Data Exchange Types Custom Layouts Voice Actions Watch Faces Creating a watchface Demo Notifications Wolfram Integration Google-Inspired Watch Face
  2. There’s definitely something wrong about this picture You are supposed to be connected to the people around you and not to those who are not currently with you
  3. Google has been trying hard to solve that problem and Android wear aims to solve that By giving you contextual information at the right moment, in just a glance
  4. There are lots of times where we get lost in phone And we tend to keep on checking the notifications on our phone particularly during special events in which you are supposed to be enjoying the moment with your loved ones.
  5. With wearables, this is what your typical day timeline will look like. You stay connected with the people around you, but still get enough time to be connected to the virtual world.
  6. Android Wear by definition is a set of APIs based on Android operating system designed specifically for wearables such as smartwatches. Simple, glanceable, built around micro-interactions It was announced this year (2014) and launched during Google I/O this year as well This is in partnership with Motorola, Samsung, LG, HTC and ASUS
  7. Now let’s talk about Notifications
  8. This is how to build a simple notification for handheld device Create a pending intent Create a notification by using the builder that is part of the Notification compatibility library Create an instance of notification manager Send the notification
  9. This is how it looks on a handheld device and wearable device
  10. Existing notifications on your phone will be displayed on the wearable And to get this done…
  11. …you don’t have to do anything It already works out of the box. Also, notifications that buzz or sound on the companion device, will also buzz on the wearable
  12. And that is why Android wear provided us with three more features you can easily take advantage of by adding a few more lines of code to your Android app
  13. Stacks are like inbox-style notifications. You can deliver multiple items in a single bundle Let’s take a look on how this is implemented in code
  14. Here, we are creating 3 notifications First two are actual messages Last one is the summary notification All of them can be bundled together using the setGroup method Send all of the notifications through the notify method
  15. Stacked notifications allow you to group multiple similar notifications into a single card which users can expand to view the details from each notification separately. Summary notification will only be displayed on the handheld device.
  16. Pages are for showing multiple screens of information on the same topic, but remember to stay glance able and try to keep things short and simple
  17. First, we build our page, which is basically another notification We need to specify the card style that we want to use: There are 3 styles available for pages: BigPictureStyle BigTextStyle InboxStyle
  18. then let’s build our main notification Extend the main notification and add the page that we have created previously Send the notification
  19. The main notification displays on the handheld But in the wearable device, you will see another page when you swipe to the left.
  20. Replies allow the user to reply directly from the wearable via voice.
  21. To build a reply action, first create a remote input object. You can specify the label as well as the pre-defined choices The choices allows the user to scroll through the choices quickly
  22. Next, create an Action object and specify the remote input that we have created previously. replyPendingIntent points to a class that will receive the intent after the user finishes the reply. Create the main notification and extend it. Add the action object to your main notification Send the notification
  23. So this is how it looks like when a notification has a reply action Users can easily respond to the message by either saying their response or by selecting from pre-defined response
  24. Remember that we have a replyPendingIntent that points to a class to receive the Intent. This is a sample code that will fetch the actual text response from the voice input Do not use Intent.getExtras() to obtain the voice result, because the voice input is stored as ClipData. The getResultsFromIntent() method provides a convenient way to receive a character sequence without having to process the ClipData yourself.
  25. Now let’s talk about Wearable Apps
  26. System enforces timeout period If you are displaying an activity and user's don't interact with it, the device sleeps. When it wakes back up, the Wear home screen is displayed instead of your activity. If you need to show something persistent, create a notification in the context stream instead. Relatively small in size and functionality They contain only what makes sense on the wearable, which is usually a small subset of the corresponding handheld app. In general, you should carry out operations on the handheld when possible and send the results to the wearable. Users don’t download apps directly to wearable Instead, you bundle the wearable app inside the handheld app. When users install the handheld app, the system automatically installs the wearable app. However, for development purposes, you can still install the wearable app directly to the wearable. Don’t support the following APIs You can check if a wearable supports a feature by calling hasSystemFeature() before trying to use an API.
  27. I’ll quickly go through the wizard screens in Android Studio on how to create a wearable app
  28. Specify your application name and company domain. The company domain will be used as part of the classes’ package name as well as the app’s identifier
  29. Here, you can specify the minimum API level that your app is going to support. And since we are building app for Android Wear, we need to check the Wear checkbox and select the minimum SDK to be API 20.
  30. You can specify the type of activity that you want to use for the handheld app
  31. Set the activity name as well as the activity’s layout name
  32. And you can also specify the type of activity for the wearable app. But as of now, you can only choose black wear activity.
  33. Of course, you can also specify the activity’s name and layout name
  34. After the wizard, you’ll see a project structure similar to this. The project has two modules: one for handheld app called mobile and one for wearable app called wear. If you want to deploy and test your handheld app, just select mobile from the Run dropdown, otherwise, choose Wear to deploy and test your wearable app.
  35. Sharing data between the phone and the wearable Custom UI options How to integrate voice
  36. The connection between phone and wearable is provided by Google Play Services The application can send data between the phone and the watch through asynchronous calls via Google Play Services.
  37. There are three types of data exchange [click] Node API helps you know when two devices are connected, which is when you can exchange data and messages between your phone and the wearable. [click] Message API allows you to exchange low latency messages. Great for RPCs. [click] Data API give you the ability to store data that’s shared between the phone and wearable and automatically buffered when the devices are disconnected
  38. Node API Can get connected nodes at any time Or be notified when a peer connects or disconnects
  39. Node API Can get connected nodes at any time Or be notified when a peer connects or disconnects
  40. Message API Send a message and be notified when one is received
  41. Implement MessageListener Override onMessageReceived
  42. Data API Put and Get data items Get notified when data is changed
  43. Implement DataListener Override onDataChanged Data type: DELETED, CHANGED
  44. To receive data, you will need the WearableListenerService You would usually create instances of this service in both your wearable and handheld apps. If you don't care about receiving data events in one of these apps, then you don't need to implement this service in that particular app. Simply create a class that extends WearableListenerService. Listen for the events that you care about, such as onDataChanged().
  45. Declare an intent filter in your Android manifest to notify the system about your WearableListenerService. This allows the system to bind your service as needed.
  46. Now we’ll talk about custom layouts
  47. In general, you should create notifications on the handheld and let them automatically sync to the wearable. This lets you build your notifications once and have them appear on many types of devices. If the standard notification styles don't work for you (such as NotificationCompat.BigTextStyle or NotificationCompat.InboxStyle), you can display an activity with a custom layout. You can only create and issue custom notifications on the wearable, and the system does not sync these notifications to the handheld. There’s a UI support library that helps you build UIs that are designed for wearables. It’s automatically included when you create your wearable app with the Android Studio Project Wizard.
  48. These are some of the major classes you get
  49. A class that can inflate a specific layout, depending on the shape of the device's screen.
  50. A FrameLayout that's aware of screen shape and can box its children in the center square of a round screen.
  51. DelayedConfirmationView shows users an animated timer that lets them cancel an action they just performed. ConfirmationActivity gives users visual feedback when they complete an action.
  52. Cards present information to users with a consistent look and feel across different apps.
  53. Now let’s talk about voice actions. Voice actions allow you to use the built-in speech input API to launch an app or as a way for your users to input values
  54. [click] System-provided actions are task-based and built into the wear platform and specified with an intent-filter. [click] App-provided actions are app-based and are declared like a launcher icon. [click] Free-form Speech Input uses the Speech Recognizer activity to get speech input from the user.
  55. System provided voice actions You filter for them in the activity that you want to start when the voice action is spoken. Examples include "Take a note" or "Set an alarm".
  56. These are the commands available on Android Wear today
  57. App provided voice actions These voice actions are app-based, and you declare them just like a launcher icon. Users say "Start " to use these voice actions and an activity that you specify starts.
  58. Speech recognizer In addition to using voice actions to launch activities, you can also call the system's built-in Speech Recognizer activity to obtain speech input from users. This is useful to obtain input from users and then process it, such as doing a search or sending it as a message.
  59. Ok, now let’s move on to watch faces