SlideShare a Scribd company logo
+GabrieleMariotti
@GabMarioPower
Introduction to Android Wear
What is Android Wear ?
Android Wear extends the Android platform to a new generation of
wearable devices
How does it work ?
How does it work ?
● Phone and wearable communicate with each other over BT
● Require Android 4.3+ on phone/tablet
● Wearable itself doesn’t connect to internet
● Limited function when connection is lost
● Current available sensors are Compass, Accelerometer, Gyroscope,
Heart Rate Sensor(*)
BATTERY LIFE:
24-36 Hrs
Custom OS Android Wear
Watches and Android Wear watches
Right information at just the right time
Right information at just the right time
Launched automatically
Right information at just the right time
Glanceable
Right information at just the right time
Suggest and demand
Right information at just the right time
Zero or low interaction
Apps on wear
Apps on wear
Apps on wear
Hands on…..
Android Wear Project Wizard
Use Android Studio!
http://goo.gl/ZSJH5O
Android Studio is optimized for Wear
Android Wear Project Wizard
Android Wear Project Wizard
Project structure
Wear Model : Notification
Mobile
Module
Wear
Module
?
Notification: simple example
Notification: basic example
NO WORK
REQUIRED
JAVA
Notification : basic example (1)
// Notification
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(“Notification Title”)
.setContentText(“Notification Text”)
.setContentIntent(mPendingIntent);
JAVA
Notification : basic example (2)
// Get an instance of the NotificationManager service
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(mContext);
// Build the notification and issues it with notification manager.
notificationManager.notify(notificationId, notificationBuilder.build());
Notification: long text
Notification: long text
NO WORK
REQUIRED
JAVA
Notification : long text
//BigText
NotificationCompat.BigTextStyle bigStyle = new
NotificationCompat.BigTextStyle();
bigStyle.setBigContentTitle(“Big Title”);
bigStyle.bigText(“Lorem ipsum……..”);
// Notification
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.ic_launcher).setStyle(bigStyle)
.setContentIntent(mPendingIntent);
Notification: big picture
Notification: big picture
NO WORK
REQUIRED
NO WORK
REQUIRED
JAVA
Notification : big picture
//BigPicture
NotificationCompat.BigPictureStyle bigStyle = new NotificationCompat.BigPictureStyle();
bigStyle.bigPicture
(BitmapFactory.decodeResource(mContext.getResources(),R.drawable.large_image));
bigStyle.setBigContentTitle(“Big Title”);
bigStyle.setSummaryText(“Notification Text”);
// Notification
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.ic_launcher).setStyle(bigStyle)
.setContentIntent(mPendingIntent);
Notification: pages
JAVANotificationCompat.BigPictureStyle bigStyle = new NotificationCompat.BigPictureStyle();
bigStyle.bigPicture
(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.large_image));
bigStyle.setBigContentTitle(“Second Page”);
// Create second page notification
Notification secondPageNotification =
new NotificationCompat.Builder(mContext)
.setStyle(bigStyle)
.build();
Notification: pages
JAVA// Notification
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(“Notification Title”)
.setContentText(“Notification Text”)
.extend(
new NotificationCompat.WearableExtender().addPage(secondPageNotification))
.setContentIntent(mPendingIntent);
Notification: pages
Notification: stacks
JAVA// Notification
NotificationCompat.Builder notificationBuilder1 =
new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(“Notification Title”)
.setContentText("Alex New meeting")
.setGroup(GROUP_KEY_EMAILS)
.setContentIntent(mPendingIntent)
.setSortKey("0");
notificationManager.notify(notificationId, notificationBuilder1.build());
Notification: stacks (1)
JAVANotificationCompat.Builder notificationBuilder2 =
new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(“Notification Title”)
.setContentText("Peter Next week")
.setGroup(GROUP_KEY_EMAILS)
.setContentIntent(mPendingIntent)
.setSortKey("1");
notificationManager.notify(notification2Id, notificationBuilder2.build());
Notification: stacks (2)
JAVA
// Create an InboxStyle notification
Notification summaryNotificationWithBackground =
new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.ic_launcher).setLargeIcon(largeIcon)
.setStyle(new NotificationCompat.InboxStyle()
.addLine("Alex New meeting")
.addLine("Peter Next week")
.setBigContentTitle("2 new messages")
.setSummaryText("johndoe@gmail.com"))
.setGroup(GROUP_KEY_EMAILS).setGroupSummary(true).build();
notificationManager.notify(notification3Id, summaryNotificationWithBackground);
Notification: stacks (3)
Notification: actions
Notification: actions
NO WORK
REQUIRED
JAVA// Notification
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(“Notification Title”)
.setContentText(“Notification Text”)
.addAction(R.drawable.ic_full_action, “Simple Action”,mPendingActionIntent)
.setContentIntent(mPendingIntent);
Notification: simple action
Notification: reply action
JAVANotificationCompat.Action action = new NotificationCompat.Action.Builder(
R.drawable.ic_full_reply,“Reply”,mPendingIntent)
.addRemoteInput(mNotificationUtil.getReplyAction())
.build();
public RemoteInput getReplyAction(){
RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
.setLabel(“Reply”).build();
return remoteInput;
}
Notification: reply action (1)
JAVA// Notification
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(“Notification Title”)
.setContentText(“Notification Text”)
.extend(new NotificationCompat.WearableExtender().addAction(action));
Notification: reply action (2)
Notification: reply action with choices
JAVApublic RemoteInput getReplyActionWithPredefinedTextResponses(){
RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
.setLabel(“Reply”)
.setChoices(mContext.getResources().getStringArray(R.array.reply_choices))
.build();
return remoteInput;
}
<string-array name="reply_choices">
<item>Yes</item>
<item>No</item>
</string-array>
Notification: reply action with choices
Wear Model : Connection
Mobile
Module
Wear
Module
GoogleApi
Client
GoogleApi
Client
JAVA
GoogleApiClient
Connection
//Connect the GoogleApiClient
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
JAVA
GoogleApiClient
Connection
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
@Overrire
protected void onStop(){
super.onStop();
mGoogleApiClient.disconnect();
}
JAVA
Connected Nodes
Connection
private void resolveNode() {
Wearable.NodeApi.getConnectedNodes(mGoogleApiClient)
.setResultCallback(new ResultCallback<NodeApi.GetConnectedNodesResult>() {
@Override
public void onResult(NodeApi.GetConnectedNodesResult nodes) {
for (Node node : nodes.getNodes()) {
//…..
}
}
});
}
JAVA
Node - Listeners
Connection
public interface NodeApi.NodeListener {
void onPeerConnected(com.google.android.gms.wearable.Node node);
void onPeerDisconnected(com.google.android.gms.wearable.Node node);
}
Example:
public class MyActivity extends Activity implements NodeApi.NodeListener {
public void onConnected(Bundle bundle) {
Wearable.NodeApi.addListener(mGoogleApiClient, this);
}
}
Wear Model : Message
Message Message
Message Message
JAVA
Wearable.MessageApi.sendMessage(
mGoogleApiClient, nodeId, PATH, payload).setResultCallback(
new ResultCallback<MessageApi.SendMessageResult>() {
@Override
public void onResult(MessageApi.SendMessageResult sendMessageResult) {
//……….
}
}
);
Message
MessageAPI
JAVA
Message - Listener
Message
interface MessageApi.MessageListener {
void onMessageReceived(com.google.android.gms.wearable.MessageEvent messageEvent);
}
Example:
public class MyActivity extends Activity implements MessageApi.MessageListener {
public void onConnected(Bundle bundle) {
Wearable.MessageApi.addListener(mGoogleApiClient, this);
}
}
Wear Model : Data
Data Data
JAVAPutDataMapRequest dataMap = PutDataMapRequest.create("/count");
dataMap.getDataMap().putInt(COUNT_KEY, count++);
//dataMap.getDataMap().putString(“/myItemId”, “Hello World”);
PutDataRequest request = dataMap.asPutDataRequest();
PendingResult<DataApi.DataItemResult> pendingResult =
Wearable.DataApi.putDataItem(mGoogleApiClient, request);
Data
DataAPI
JAVA
Data - Listener
Data
interface DataApi.DataListener {
void onDataChanged(com.google.android.gms.wearable.DataEventBuffer dataEventBuffer);
}
Example:
public class MyActivity extends Activity implements DataApi.DataListener {
public void onConnected(Bundle bundle) {
Wearable.DataApi.addListener(mGoogleApiClient, this);
}
}
Wear Model : Message/Data
Activity Activity
WearableListenerSer
vice
WearableListenerSer
vice
JAVA
Activity
Receiving Message
public classs MyActivity extends Activity implements MessageApi.MessageListener {
//Add the listener in onConnected() method
@Override
public void onMessageReceived(MessageEvent messageEvent) {
if (messageEvent.getPath().equals(PATH)) {
byte[] bytes = messageEvent.getData();
}
}
}
JAVA
Service
Receiving Message
<service android:name=".MyListenerService">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
public classs MyListenerService extends WearableListenerService {
@Override
public void onMessageReceived(MessageEvent messageEvent) {
//…………..
}
JAVA
Activity
Receiving Data
public classs MyActivity extends Activity implements DataApi.DataListener {
//Add the listener in onConnected() method
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_DELETED) {
Log.d(TAG, "DataItem deleted: " + event.getDataItem().getUri());
} else if (event.getType() == DataEvent.TYPE_CHANGED) {
Log.d(TAG, "DataItem changed: " + event.getDataItem().getUri());
}
}
}
JAVA
Service
Receiving Data
<service android:name=".MyListenerService">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
public classs MyListenerService extends WearableListenerService {
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
//…………..
}
JAVA
Example: launch Activity on mobile from wear
SendMessageActivity extends Activity {
…
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.build();
}
wear/SendMessageActivity.java
JAVA
Example: launch Activity on mobile from wear
…
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
@Override
protected void onStop() {
super.onStop();
mGoogleApiClient.disconnect();
}
wear/SendMessageActivity.java
JAVA
Example: launch Activity on mobile from wear
private void resolveNode() {
Wearable.NodeApi.getConnectedNodes(mGoogleApiClient)
.setResultCallback(new ResultCallback<NodeApi.GetConnectedNodesResult>() {
@Override
public void onResult(NodeApi.GetConnectedNodesResult nodes) {
for (Node node : nodes.getNodes()) {
sendMessage(node);
}
}
});
}
wear/SendMessageActivity.java
JAVA
Example: launch Activity on mobile from wear
static final String HELLO_WORLD_WEAR_PATH = "/hello-world-wear";
private void sendMessage(Node node){
Wearable.MessageApi.sendMessage(
mGoogleApiClient, node.getId(), HELLO_WORLD_WEAR_PATH,null)
.setResultCallback(new ResultCallback<MessageApi.SendMessageResult>() {
@Override
public void onResult(MessageApi.SendMessageResult sendMessageResult) {
if (!sendMessageResult.getStatus().isSuccess()) {
Log.e("TAG", "Failed to send message with status code: "
+ sendMessageResult.getStatus().getStatusCode());
}
}
}
);
}
wear/SendMessageActivity.java
JAVA
Example: launch Activity on mobile from wear
public class ListenerServiceFromWear extends WearableListenerService {
private static final String WEAR_PATH = "/hello-world-wear";
@Override
public void onMessageReceived(MessageEvent messageEvent) {
if (messageEvent.getPath().equals(WEAR_PATH)) {
Intent startIntent = new Intent(this, EmptyActivity.class);
startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startIntent);
}
}
}
mobile/ListenerService.java
JAVA
Example: launch Activity on mobile from wear
You can find the full code here:
https://gist.github.com/gabrielemariotti/117b05aad4db251f7534
References and Credits
- Getting Started with Android Wear
http://developer.android.com/wear
- Build apps for Wearables
http://developer.android.com/training/building-wearables.html
- Thanks to Mario Viviani for some slides and ideas from
Kick-Start Your Experience with Android Wear
+GabrieleMariotti
@GabMarioPower
Thank you!

More Related Content

Similar to Introduction to Android Wear

Local Notification Tutorial
Local Notification TutorialLocal Notification Tutorial
Local Notification Tutorial
Ketan Raval
 
"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila
"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila
"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila
Giuseppe Cerratti
 
Android Wear Development
Android Wear DevelopmentAndroid Wear Development
Android Wear Development
Takahiro (Poly) Horikawa
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
Emanuele De Bernardi
 
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
mharkus
 
Android Wear – IO Extended
Android Wear – IO ExtendedAndroid Wear – IO Extended
Android Wear – IO Extended
Douglas Drumond
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
AbdullahMunir32
 
8º Betabeers Granada: Android Wear por GDG Granada
8º Betabeers Granada: Android Wear por GDG Granada8º Betabeers Granada: Android Wear por GDG Granada
8º Betabeers Granada: Android Wear por GDG Granada
JM Robles
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
Abid Khan
 
Android wear and Cardboard
Android wear and CardboardAndroid wear and Cardboard
Android wear and Cardboardmharkus
 
Android应用开发简介
Android应用开发简介Android应用开发简介
Android应用开发简介
easychen
 
Android Wear 2.0 - IT NonStop Dnipro
Android Wear 2.0 - IT NonStop DniproAndroid Wear 2.0 - IT NonStop Dnipro
Android Wear 2.0 - IT NonStop Dnipro
Constantine Mars
 
Android wear (coding)
Android wear (coding)Android wear (coding)
Android wear (coding)
Douglas Drumond
 
Android notifications
Android notificationsAndroid notifications
Android notificationsKetan Raval
 
Android Notifications in Android Nougat 7.0
Android Notifications in Android Nougat 7.0Android Notifications in Android Nougat 7.0
Android Notifications in Android Nougat 7.0
Gracia Marcom
 
Droidcon Turin 2015 - Android wear sdk introduction
Droidcon Turin 2015 - Android wear sdk introductionDroidcon Turin 2015 - Android wear sdk introduction
Droidcon Turin 2015 - Android wear sdk introduction
Michelantonio Trizio
 
Android wear SDK introduction
Android wear SDK introductionAndroid wear SDK introduction
Android wear SDK introduction
Tiziano Basile
 
Android studio
Android studioAndroid studio
Android studio
Andri Yabu
 
ハンズオン資料 電話を作ろう(v2.x用)
ハンズオン資料 電話を作ろう(v2.x用)ハンズオン資料 電話を作ろう(v2.x用)
ハンズオン資料 電話を作ろう(v2.x用)
Kenji Sakashita
 
Basic Intro to android(Will be updating later)
Basic Intro to android(Will be updating later)Basic Intro to android(Will be updating later)
Basic Intro to android(Will be updating later)
Sanju Sony Kurian
 

Similar to Introduction to Android Wear (20)

Local Notification Tutorial
Local Notification TutorialLocal Notification Tutorial
Local Notification Tutorial
 
"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila
"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila
"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila
 
Android Wear Development
Android Wear DevelopmentAndroid Wear Development
Android Wear Development
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
 
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
 
Android Wear – IO Extended
Android Wear – IO ExtendedAndroid Wear – IO Extended
Android Wear – IO Extended
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
 
8º Betabeers Granada: Android Wear por GDG Granada
8º Betabeers Granada: Android Wear por GDG Granada8º Betabeers Granada: Android Wear por GDG Granada
8º Betabeers Granada: Android Wear por GDG Granada
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android wear and Cardboard
Android wear and CardboardAndroid wear and Cardboard
Android wear and Cardboard
 
Android应用开发简介
Android应用开发简介Android应用开发简介
Android应用开发简介
 
Android Wear 2.0 - IT NonStop Dnipro
Android Wear 2.0 - IT NonStop DniproAndroid Wear 2.0 - IT NonStop Dnipro
Android Wear 2.0 - IT NonStop Dnipro
 
Android wear (coding)
Android wear (coding)Android wear (coding)
Android wear (coding)
 
Android notifications
Android notificationsAndroid notifications
Android notifications
 
Android Notifications in Android Nougat 7.0
Android Notifications in Android Nougat 7.0Android Notifications in Android Nougat 7.0
Android Notifications in Android Nougat 7.0
 
Droidcon Turin 2015 - Android wear sdk introduction
Droidcon Turin 2015 - Android wear sdk introductionDroidcon Turin 2015 - Android wear sdk introduction
Droidcon Turin 2015 - Android wear sdk introduction
 
Android wear SDK introduction
Android wear SDK introductionAndroid wear SDK introduction
Android wear SDK introduction
 
Android studio
Android studioAndroid studio
Android studio
 
ハンズオン資料 電話を作ろう(v2.x用)
ハンズオン資料 電話を作ろう(v2.x用)ハンズオン資料 電話を作ろう(v2.x用)
ハンズオン資料 電話を作ろう(v2.x用)
 
Basic Intro to android(Will be updating later)
Basic Intro to android(Will be updating later)Basic Intro to android(Will be updating later)
Basic Intro to android(Will be updating later)
 

Recently uploaded

Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 

Recently uploaded (20)

Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 

Introduction to Android Wear

  • 2.
  • 3. What is Android Wear ? Android Wear extends the Android platform to a new generation of wearable devices
  • 4. How does it work ?
  • 5. How does it work ? ● Phone and wearable communicate with each other over BT ● Require Android 4.3+ on phone/tablet ● Wearable itself doesn’t connect to internet ● Limited function when connection is lost ● Current available sensors are Compass, Accelerometer, Gyroscope, Heart Rate Sensor(*)
  • 7. Custom OS Android Wear Watches and Android Wear watches
  • 8. Right information at just the right time
  • 9. Right information at just the right time Launched automatically
  • 10. Right information at just the right time Glanceable
  • 11. Right information at just the right time Suggest and demand
  • 12. Right information at just the right time Zero or low interaction
  • 17. Android Wear Project Wizard Use Android Studio! http://goo.gl/ZSJH5O Android Studio is optimized for Wear
  • 21. Wear Model : Notification Mobile Module Wear Module ?
  • 24. JAVA Notification : basic example (1) // Notification NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mContext) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(“Notification Title”) .setContentText(“Notification Text”) .setContentIntent(mPendingIntent);
  • 25. JAVA Notification : basic example (2) // Get an instance of the NotificationManager service NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mContext); // Build the notification and issues it with notification manager. notificationManager.notify(notificationId, notificationBuilder.build());
  • 27. Notification: long text NO WORK REQUIRED
  • 28. JAVA Notification : long text //BigText NotificationCompat.BigTextStyle bigStyle = new NotificationCompat.BigTextStyle(); bigStyle.setBigContentTitle(“Big Title”); bigStyle.bigText(“Lorem ipsum……..”); // Notification NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mContext) .setSmallIcon(R.drawable.ic_launcher).setStyle(bigStyle) .setContentIntent(mPendingIntent);
  • 30. Notification: big picture NO WORK REQUIRED NO WORK REQUIRED
  • 31. JAVA Notification : big picture //BigPicture NotificationCompat.BigPictureStyle bigStyle = new NotificationCompat.BigPictureStyle(); bigStyle.bigPicture (BitmapFactory.decodeResource(mContext.getResources(),R.drawable.large_image)); bigStyle.setBigContentTitle(“Big Title”); bigStyle.setSummaryText(“Notification Text”); // Notification NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mContext) .setSmallIcon(R.drawable.ic_launcher).setStyle(bigStyle) .setContentIntent(mPendingIntent);
  • 33. JAVANotificationCompat.BigPictureStyle bigStyle = new NotificationCompat.BigPictureStyle(); bigStyle.bigPicture (BitmapFactory.decodeResource(mContext.getResources(), R.drawable.large_image)); bigStyle.setBigContentTitle(“Second Page”); // Create second page notification Notification secondPageNotification = new NotificationCompat.Builder(mContext) .setStyle(bigStyle) .build(); Notification: pages
  • 34. JAVA// Notification NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mContext) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(“Notification Title”) .setContentText(“Notification Text”) .extend( new NotificationCompat.WearableExtender().addPage(secondPageNotification)) .setContentIntent(mPendingIntent); Notification: pages
  • 36. JAVA// Notification NotificationCompat.Builder notificationBuilder1 = new NotificationCompat.Builder(mContext) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(“Notification Title”) .setContentText("Alex New meeting") .setGroup(GROUP_KEY_EMAILS) .setContentIntent(mPendingIntent) .setSortKey("0"); notificationManager.notify(notificationId, notificationBuilder1.build()); Notification: stacks (1)
  • 37. JAVANotificationCompat.Builder notificationBuilder2 = new NotificationCompat.Builder(mContext) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(“Notification Title”) .setContentText("Peter Next week") .setGroup(GROUP_KEY_EMAILS) .setContentIntent(mPendingIntent) .setSortKey("1"); notificationManager.notify(notification2Id, notificationBuilder2.build()); Notification: stacks (2)
  • 38. JAVA // Create an InboxStyle notification Notification summaryNotificationWithBackground = new NotificationCompat.Builder(mContext) .setSmallIcon(R.drawable.ic_launcher).setLargeIcon(largeIcon) .setStyle(new NotificationCompat.InboxStyle() .addLine("Alex New meeting") .addLine("Peter Next week") .setBigContentTitle("2 new messages") .setSummaryText("johndoe@gmail.com")) .setGroup(GROUP_KEY_EMAILS).setGroupSummary(true).build(); notificationManager.notify(notification3Id, summaryNotificationWithBackground); Notification: stacks (3)
  • 41. JAVA// Notification NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mContext) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(“Notification Title”) .setContentText(“Notification Text”) .addAction(R.drawable.ic_full_action, “Simple Action”,mPendingActionIntent) .setContentIntent(mPendingIntent); Notification: simple action
  • 43. JAVANotificationCompat.Action action = new NotificationCompat.Action.Builder( R.drawable.ic_full_reply,“Reply”,mPendingIntent) .addRemoteInput(mNotificationUtil.getReplyAction()) .build(); public RemoteInput getReplyAction(){ RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) .setLabel(“Reply”).build(); return remoteInput; } Notification: reply action (1)
  • 44. JAVA// Notification NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mContext) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(“Notification Title”) .setContentText(“Notification Text”) .extend(new NotificationCompat.WearableExtender().addAction(action)); Notification: reply action (2)
  • 46. JAVApublic RemoteInput getReplyActionWithPredefinedTextResponses(){ RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) .setLabel(“Reply”) .setChoices(mContext.getResources().getStringArray(R.array.reply_choices)) .build(); return remoteInput; } <string-array name="reply_choices"> <item>Yes</item> <item>No</item> </string-array> Notification: reply action with choices
  • 47. Wear Model : Connection Mobile Module Wear Module GoogleApi Client GoogleApi Client
  • 48. JAVA GoogleApiClient Connection //Connect the GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Wearable.API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build();
  • 49. JAVA GoogleApiClient Connection @Override protected void onStart() { super.onStart(); mGoogleApiClient.connect(); } @Overrire protected void onStop(){ super.onStop(); mGoogleApiClient.disconnect(); }
  • 50. JAVA Connected Nodes Connection private void resolveNode() { Wearable.NodeApi.getConnectedNodes(mGoogleApiClient) .setResultCallback(new ResultCallback<NodeApi.GetConnectedNodesResult>() { @Override public void onResult(NodeApi.GetConnectedNodesResult nodes) { for (Node node : nodes.getNodes()) { //….. } } }); }
  • 51. JAVA Node - Listeners Connection public interface NodeApi.NodeListener { void onPeerConnected(com.google.android.gms.wearable.Node node); void onPeerDisconnected(com.google.android.gms.wearable.Node node); } Example: public class MyActivity extends Activity implements NodeApi.NodeListener { public void onConnected(Bundle bundle) { Wearable.NodeApi.addListener(mGoogleApiClient, this); } }
  • 52. Wear Model : Message Message Message Message Message
  • 53. JAVA Wearable.MessageApi.sendMessage( mGoogleApiClient, nodeId, PATH, payload).setResultCallback( new ResultCallback<MessageApi.SendMessageResult>() { @Override public void onResult(MessageApi.SendMessageResult sendMessageResult) { //………. } } ); Message MessageAPI
  • 54. JAVA Message - Listener Message interface MessageApi.MessageListener { void onMessageReceived(com.google.android.gms.wearable.MessageEvent messageEvent); } Example: public class MyActivity extends Activity implements MessageApi.MessageListener { public void onConnected(Bundle bundle) { Wearable.MessageApi.addListener(mGoogleApiClient, this); } }
  • 55. Wear Model : Data Data Data
  • 56. JAVAPutDataMapRequest dataMap = PutDataMapRequest.create("/count"); dataMap.getDataMap().putInt(COUNT_KEY, count++); //dataMap.getDataMap().putString(“/myItemId”, “Hello World”); PutDataRequest request = dataMap.asPutDataRequest(); PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi.putDataItem(mGoogleApiClient, request); Data DataAPI
  • 57. JAVA Data - Listener Data interface DataApi.DataListener { void onDataChanged(com.google.android.gms.wearable.DataEventBuffer dataEventBuffer); } Example: public class MyActivity extends Activity implements DataApi.DataListener { public void onConnected(Bundle bundle) { Wearable.DataApi.addListener(mGoogleApiClient, this); } }
  • 58. Wear Model : Message/Data Activity Activity WearableListenerSer vice WearableListenerSer vice
  • 59. JAVA Activity Receiving Message public classs MyActivity extends Activity implements MessageApi.MessageListener { //Add the listener in onConnected() method @Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals(PATH)) { byte[] bytes = messageEvent.getData(); } } }
  • 60. JAVA Service Receiving Message <service android:name=".MyListenerService"> <intent-filter> <action android:name="com.google.android.gms.wearable.BIND_LISTENER" /> </intent-filter> </service> public classs MyListenerService extends WearableListenerService { @Override public void onMessageReceived(MessageEvent messageEvent) { //………….. }
  • 61. JAVA Activity Receiving Data public classs MyActivity extends Activity implements DataApi.DataListener { //Add the listener in onConnected() method @Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_DELETED) { Log.d(TAG, "DataItem deleted: " + event.getDataItem().getUri()); } else if (event.getType() == DataEvent.TYPE_CHANGED) { Log.d(TAG, "DataItem changed: " + event.getDataItem().getUri()); } } }
  • 62. JAVA Service Receiving Data <service android:name=".MyListenerService"> <intent-filter> <action android:name="com.google.android.gms.wearable.BIND_LISTENER" /> </intent-filter> </service> public classs MyListenerService extends WearableListenerService { @Override public void onDataChanged(DataEventBuffer dataEvents) { //………….. }
  • 63. JAVA Example: launch Activity on mobile from wear SendMessageActivity extends Activity { … @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Wearable.API) .build(); } wear/SendMessageActivity.java
  • 64. JAVA Example: launch Activity on mobile from wear … @Override protected void onStart() { super.onStart(); mGoogleApiClient.connect(); } @Override protected void onStop() { super.onStop(); mGoogleApiClient.disconnect(); } wear/SendMessageActivity.java
  • 65. JAVA Example: launch Activity on mobile from wear private void resolveNode() { Wearable.NodeApi.getConnectedNodes(mGoogleApiClient) .setResultCallback(new ResultCallback<NodeApi.GetConnectedNodesResult>() { @Override public void onResult(NodeApi.GetConnectedNodesResult nodes) { for (Node node : nodes.getNodes()) { sendMessage(node); } } }); } wear/SendMessageActivity.java
  • 66. JAVA Example: launch Activity on mobile from wear static final String HELLO_WORLD_WEAR_PATH = "/hello-world-wear"; private void sendMessage(Node node){ Wearable.MessageApi.sendMessage( mGoogleApiClient, node.getId(), HELLO_WORLD_WEAR_PATH,null) .setResultCallback(new ResultCallback<MessageApi.SendMessageResult>() { @Override public void onResult(MessageApi.SendMessageResult sendMessageResult) { if (!sendMessageResult.getStatus().isSuccess()) { Log.e("TAG", "Failed to send message with status code: " + sendMessageResult.getStatus().getStatusCode()); } } } ); } wear/SendMessageActivity.java
  • 67. JAVA Example: launch Activity on mobile from wear public class ListenerServiceFromWear extends WearableListenerService { private static final String WEAR_PATH = "/hello-world-wear"; @Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals(WEAR_PATH)) { Intent startIntent = new Intent(this, EmptyActivity.class); startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(startIntent); } } } mobile/ListenerService.java
  • 68. JAVA Example: launch Activity on mobile from wear You can find the full code here: https://gist.github.com/gabrielemariotti/117b05aad4db251f7534
  • 69. References and Credits - Getting Started with Android Wear http://developer.android.com/wear - Build apps for Wearables http://developer.android.com/training/building-wearables.html - Thanks to Mario Viviani for some slides and ideas from Kick-Start Your Experience with Android Wear