SlideShare a Scribd company logo
1 of 34
Download to read offline
Android Wear Development
July 25, 2014
Takahiro Poly Horikawa
Agenda
• Android wear’s features and capabilities
• How to develop?
– Notification
– Sending and syncing data
• Development case study
Concept
• Microinteraction
How it works?
• Require android (>= 4.3) phone/tablet
(referred as handheld)
• Require “Android Wear” app on the handheld
• Handheld and wearable communicate each
other via Bluetooth (wearable itself does not
connect to internet)
Notifications
What you can do?
• Receive notifications and react them on the
wearable
• Control apps on the phone from the wearable
• Run wearable specific app (e.g. compass,
heart rate monitor)
• Voice search and voice action
etc…
Homescreen
…
…
Home
Cards
(Context stream)
Cue card
…
Cue cards
Voice Search and voice action
Hardware Spec
Samsung Gear Live LG G Watch
Screen
1.63" 320×320 AMOLED display
(278ppi)
1.65” 280×280 IPS LCD display
(240ppi)
OS Android 4.4W Android 4.4W
CPU 1.2GHz Snapdragon 400 1.2GHz Snapdragon 400
RAM 512MBytes 512MBytes
Storage 4GBytes 4GBytes
Weight 59g 63g
Thickness 8.9mm 9.95mm
Battery 300mAh 400mAh
Sensors (Samsung Gear Live)
• MPL Rotation Vector (Invensense)
• MPL Gravity (Invensense)
• MPL Orientation (Invensense)
• MPL Linear Accelration (Invensense)
• MPU6515 Acceleration Sensor (Invensense)
• MPU6515 Gyroscope Sensor (Invensense)
• SAMSUNG Tilt Wake Sensor (Samsung Inc.)
• SAMSUNG Significant Motion Sensor (Samsung Inc.)
• SAMSUNG Game Rotation Vector (Samsung Inc.)
• SAMSUNG Step Counter Sensor (Samsung Inc.)
• SAMSUNG Step Detector Sensor (Samsung Inc.)
• AK8963C Magnetic Sensor UnCalibrated (Asahi Kasei Microdevices)
• AK8963C Magnetic field Sensor (Asahi Kasei Microdevices)
• ADPD142 HRM Sensor Lib (ADI)
Application packaging and publishing
• When publishing to user, package a wearable
app inside a handheld app
• Wearable app will be installed on user’s
wearable automatically when user install
handheld app from Google Play Store
• A handheld app has to have the same package
name as a wearable app
ANDROID WEAR APP
DEVELOPMENT
Notification
• Add action
• Add voice reply
• Stacking notification
• Add pages
Add action
Intent intent = new Intent(context, NotificationLandingActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, 0);
Notification n = new NotificationCompat.Builder(context)
.setContentTitle("新着メッセージがあります")
.setContentText("xxさんからメッセージが届いています")
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pIntent)
.addAction(R.drawable.ic_launcher, "返信", pIntent)
.addAction(R.drawable.ic_launcher, "転送", pIntent)
.build();
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(context);
notificationManager.notify(0, n);
NotificationActivity.java (Handheld)
Add voice reply
String replyLabel = ”会議に参加しますか?";
String[] replyChoices = {"はい", "いいえ”};
RemoteInput remoteInput = new
RemoteInput.Builder(EXTRA_VOICE_REPLY)
.setLabel(replyLabel)
.setChoices(replyChoices)
.build();
Intent replyIntent =
new Intent(ctx, VoiceReceiverActivity.class);
PendingIntent replyPendingIntent =
PendingIntent.getActivity(ctx, 0, replyIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action action =
new
NotificationCompat.Action.Builder(R.drawable.i
c_launcher, "返信", replyPendingIntent)
.addRemoteInput(remoteInput)
.build();
Notification notification =
new NotificationCompat.Builder(ctx)
.extend(new
NotificationCompat.WearableExtender().addActi
on(action)).build();
NotificationManagerCompat manager =
NotificationManagerCompat.from(ctx);
manager.notify(200, notification);
NotificationActivity.java (Handheld)
Specify the action
only available on
wearableKey to receive
voice text in the
target Activity
Receive voice input
public class VoiceReceiverActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_voice_input_receiver);
Bundle remoteInput = RemoteInput.getResultsFromIntent(getIntent());
CharSequence message =
remoteInput.getCharSequence(NotificationActivity.EXTRA_VOICE_REPLY);
((TextView) findViewById(R.id.message)).setText(String.format("音声入
力メッセージは「%s」です。", message));
}
}
VoiceReceiverActivity.java (Handheld)
Stacking Notification
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
Notification card1 = new NotificationCompat.Builder(context)
.setContentText("何してますか?")
.setGroup(GROUP_KEY).setSortKey("0”).build();
notificationManager.notify(101, card1);
Notification card2 = new NotificationCompat.Builder(context)
.setContentText("手伝ってもらってもいいですか?")
.setGroup(GROUP_KEY).setSortKey("1”).build();
notificationManager.notify(102, card2);
Notification summary = new NotificationCompat.Builder(context)
.setContentTitle("新着メッセージ2件")
.setGroup(GROUP_KEY).setGroupSummary(true).build();
notificationManager.notify(100, summary);
NotificationActivity.java (Handheld)
Add pages
Notification page =
new NotificationCompat.Builder(context)
.setStyle(new NotificationCompat.BigTextStyle().bigText("メンチカツ定食
$7.99"))
.build();
Notification notification =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("xxレストラン通信")
.setContentText("本日の日替わりランチ")
.extend(new NotificationCompat.WearableExtender().addPage(page))
.build();
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(context);
notificationManager.notify(300, notification);
NotificationActivity.java (Handheld)
Notification gotcha
• Notification from the handheld can only open
an activity on the handheld
• To open/embed a custom activity on the
wearable, you need to send notification from
the wearable.
• Open a custom activity • Embed a custom activity
Custom
Activity
Send notification to open an activity
on the wearable
Intent viewIntent = new Intent(context, WatchActivity.class);
PendingIntent pendingViewIntent = PendingIntent.getActivity(context, 0, viewIntent,
0);
Notification notification = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Wearableから送信")
.setContentText("Wearableから送信したNotificationです。")
.addAction(R.drawable.ic_launcher, "Open", pendingViewIntent)
.setLocalOnly(true)
.extend(new
NotificationCompat.WearableExtender().setContentAction(0).setHintHideIcon(true))
.build();
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(context);
notificationManager.notify(3000, notification);
WatchActivity.java (Wearable)
Specify the default
action to be
triggered when user
tap the notification
Send notification embedding an
activity on the wearable
Intent viewIntent = new Intent(context, NotificationEmbeddedActivity.class);
PendingIntent pendingViewIntent = PendingIntent.getActivity(context, 0, viewIntent, 0);
Notification notification = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Wearableから送信")
.setContentText("Wearableから送信したNotificationです。")
.setLocalOnly(true)
.extend(new
NotificationCompat.WearableExtender().setDisplayIntent(pendingViewIntent))
.build();
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(context);
notificationManager.notify(4000, notification);
WatchActivity.java (Wearable)
Custom
Activity
Specify the Pending
Intent of activity to
be embedded in the
notification
Sending and syncing data
• Message API
– Fire and forgot, one way request
– You can send just a string
– Use case example
• Control media player from the wearable
• Data API
– Sync data between the handheld and wearable
– Payload is a byte array (100KB per item), but you can
use map interface to access data
– Use case example
• Send Photo preview from the handheld to wearable
Connect Google Api Client
private GoogleApiClient mGoogleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(Bundle bundle) {
Log.d(TAG, "Google Api Client connected");
}
@Override
public void onConnectionSuspended(int i) {
}
}).build();
mGoogleApiClient.connect();
}
DataActivity.java (Handheld)
Message API
private void sendMessageToStartActivity() {
Collection<String> nodes = getNodes();
for (String node : nodes) {
Wearable.MessageApi.sendMessage(mGoogleApiClient, node, START_ACTIVITY_PATH,
null).await();
}
}
private Collection<String> getNodes() {
HashSet<String> results = new HashSet<String>();
NodeApi.GetConnectedNodesResult nodes =
Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await();
for (Node node : nodes.getNodes()) {
results.add(node.getId());
}
return results;
}
DataActivity.java (Handheld)
Message API
public class DataLayerListenerService extends WearableListenerService {
@Override
public void onMessageReceived(MessageEvent messageEvent) {
if (START_ACTIVITY_PATH.equals(messageEvent.getPath())) {
Intent intent = new Intent(this, WatchActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
return;
}
}
}
<service android:name=".DataLayerListenerService">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
AndroidManifest.xml (Wearable)
DataLayerListenerService.java (Wearable)
Data API
send data from handheld
int count = 0;
private void sendCount() {
PutDataMapRequest dataMap = PutDataMapRequest.create(COUNT_PATH);
dataMap.getDataMap().putInt(COUNT_KEY, ++count);
PutDataRequest request = dataMap.asPutDataRequest();
PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi
.putDataItem(mGoogleApiClient, request);
pendingResult.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(DataApi.DataItemResult dataItemResult) {
Log.d(TAG, "count updated:" + count);
}
});
}
DataActivity.java (Handheld)
Data API
detect data change on wearable
public class DataLayerListenerService extends WearableListenerService {
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent event : dataEvents) {
DataItem dataItem = event.getDataItem();
if (COUNT_PATH.equals(dataItem.getUri().getPath())) {
DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap();
int count = dataMap.getInt(COUNT_KEY);
….
}
}
}
}
DataLayerListenerService.java (Wearable)
Data API
access to the existing data
private void restoreCurrentCount() {
String localNodeId = getLocalNodeId();
Uri uri = new
Uri.Builder().scheme(PutDataRequest.WEAR_URI_SCHEME).authority(localNodeId).path(COUNT_PATH).buil
d();
Wearable.DataApi.getDataItem(mGoogleApiClient, uri).setResultCallback(new
ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(DataApi.DataItemResult dataItemResult) {
DataItem dataItem = dataItemResult.getDataItem();
if (dataItem != null) {
DataMap dataMap = DataMapItem.fromDataItem(dataItemResult.getDataItem()).getDataMap();
count = dataMap.getInt(COUNT_KEY);
}
}
});
}
private String getLocalNodeId() {
NodeApi.GetLocalNodeResult nodeResult = Wearable.NodeApi.getLocalNode(mGoogleApiClient).await();
return nodeResult.getNode().getId();
}
DataActivity.java (Handheld)
The uri of data is
wear://<NODE_ID>/<PAT
H>
Node ID is required
to send message
Combination (1)
• Update embedded activity in notification from
the handheld
Data API
Notification with
DisplayIntent
Data API
Notification with
DisplayIntent
Data API
Notification with
DisplayIntent
Example: Google Map navigation on wearable
Combination (2)
• Send notification from handheld to wearable
to open a custom activity on wearable
Data API Notification Tap to open
Custom Activity
Message API
Example: Remote shutter for Google Camera app
DEVELOPMENT CASE STUDY
Draw Watch for Android Wear
• https://play.google.com/store/apps/details?id
=com.polysfactory.drawwatch
Android Wear Development
Random stuff I leaned
• Prevent default behavior of wearable (right
swipe to dismiss app)
– Place close menu on the second screen, but it is
very confusing
• Starting app from cue card is a little bit
annoying, it’s better to use notification
• Using Message API to share bitmap on the
handheld works great
All sample code is available at github
https://github.com/thorikawa/AndroidWearSampleJp

More Related Content

What's hot

Android Wear Development
Android Wear DevelopmentAndroid Wear Development
Android Wear DevelopmentJohnny Sung
 
Session #8 adding magic to your app
Session #8  adding magic to your appSession #8  adding magic to your app
Session #8 adding magic to your appVitali Pekelis
 
Titanium appcelerator sdk
Titanium appcelerator sdkTitanium appcelerator sdk
Titanium appcelerator sdkAlessio Ricco
 
What’s New in iOS 8 SDK ?
What’s New in iOS 8 SDK ?What’s New in iOS 8 SDK ?
What’s New in iOS 8 SDK ?E2LOGY
 
Android On Your Sleeve - DroidCon Montreal 2015
Android On Your Sleeve - DroidCon Montreal 2015Android On Your Sleeve - DroidCon Montreal 2015
Android On Your Sleeve - DroidCon Montreal 2015Neal Sanche
 
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
 
UI Testing for Your Xamarin.Forms Apps
UI Testing for Your Xamarin.Forms AppsUI Testing for Your Xamarin.Forms Apps
UI Testing for Your Xamarin.Forms AppsCodrina Merigo
 
Android wear SDK introduction
Android wear SDK introductionAndroid wear SDK introduction
Android wear SDK introductionTiziano Basile
 
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 introductionMichelantonio Trizio
 
Exercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callExercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callmaamir farooq
 
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
 
Developing Your First Android Wear App
Developing Your First Android Wear AppDeveloping Your First Android Wear App
Developing Your First Android Wear AppJames Montemagno
 
Developing for android wear
Developing for android wearDeveloping for android wear
Developing for android wearThomas Oldervoll
 
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...将之 小野
 
Android studio
Android studioAndroid studio
Android studioAndri Yabu
 
Augmented Reality - A look before you leap
Augmented Reality - A look before you leapAugmented Reality - A look before you leap
Augmented Reality - A look before you leapGnana Sundar Rajendiran
 

What's hot (20)

Android Wear Development
Android Wear DevelopmentAndroid Wear Development
Android Wear Development
 
Android Wearable App
Android Wearable AppAndroid Wearable App
Android Wearable App
 
Session #8 adding magic to your app
Session #8  adding magic to your appSession #8  adding magic to your app
Session #8 adding magic to your app
 
Titanium appcelerator sdk
Titanium appcelerator sdkTitanium appcelerator sdk
Titanium appcelerator sdk
 
What’s New in iOS 8 SDK ?
What’s New in iOS 8 SDK ?What’s New in iOS 8 SDK ?
What’s New in iOS 8 SDK ?
 
Android On Your Sleeve - DroidCon Montreal 2015
Android On Your Sleeve - DroidCon Montreal 2015Android On Your Sleeve - DroidCon Montreal 2015
Android On Your Sleeve - DroidCon Montreal 2015
 
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...
 
UI Testing for Your Xamarin.Forms Apps
UI Testing for Your Xamarin.Forms AppsUI Testing for Your Xamarin.Forms Apps
UI Testing for Your Xamarin.Forms Apps
 
Intro to appcelerator
Intro to appceleratorIntro to appcelerator
Intro to appcelerator
 
How to create android push notifications with custom view
How to create android push notifications with custom viewHow to create android push notifications with custom view
How to create android push notifications with custom view
 
Android wear SDK introduction
Android wear SDK introductionAndroid wear SDK introduction
Android wear SDK introduction
 
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
 
Exercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callExercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone call
 
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
 
Developing Your First Android Wear App
Developing Your First Android Wear AppDeveloping Your First Android Wear App
Developing Your First Android Wear App
 
Developing for android wear
Developing for android wearDeveloping for android wear
Developing for android wear
 
Android
AndroidAndroid
Android
 
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...
 
Android studio
Android studioAndroid studio
Android studio
 
Augmented Reality - A look before you leap
Augmented Reality - A look before you leapAugmented Reality - A look before you leap
Augmented Reality - A look before you leap
 

Similar to Android Wear Development

Android Wear – IO Extended
Android Wear – IO ExtendedAndroid Wear – IO Extended
Android Wear – IO ExtendedDouglas Drumond
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Weargabrielemariotti
 
Local Notification Tutorial
Local Notification TutorialLocal Notification Tutorial
Local Notification TutorialKetan 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'AquilaGiuseppe Cerratti
 
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
 
Android wear and Cardboard
Android wear and CardboardAndroid wear and Cardboard
Android wear and Cardboardmharkus
 
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
 
June 2014 - Android wear
June 2014 - Android wearJune 2014 - Android wear
June 2014 - Android wearBlrDroid
 
Synapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindiappsdevelopment
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorialSynapseindiappsdevelopment
 
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...Ted Chien
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart JfokusLars Vogel
 
Android notification
Android notificationAndroid notification
Android notificationKrazy Koder
 
Android appwidget
Android appwidgetAndroid appwidget
Android appwidgetKrazy Koder
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recieversUtkarsh Mankad
 
Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Alfredo Morresi
 

Similar to Android Wear Development (20)

Android Wear – IO Extended
Android Wear – IO ExtendedAndroid Wear – IO Extended
Android Wear – IO Extended
 
DAY2.pptx
DAY2.pptxDAY2.pptx
DAY2.pptx
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
 
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 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
 
Android wear and Cardboard
Android wear and CardboardAndroid wear and Cardboard
Android wear and Cardboard
 
Notifications
NotificationsNotifications
Notifications
 
Android wear (coding)
Android wear (coding)Android wear (coding)
Android wear (coding)
 
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
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
 
June 2014 - Android wear
June 2014 - Android wearJune 2014 - Android wear
June 2014 - Android wear
 
Synapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindia android application development tutorial
Synapseindia android application development tutorial
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorial
 
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
viWave Study Group - Introduction to Google Android Development - Chapter 23 ...
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart Jfokus
 
Android notification
Android notificationAndroid notification
Android notification
 
Android appwidget
Android appwidgetAndroid appwidget
Android appwidget
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
 
Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)Slightly Advanced Android Wear ;)
Slightly Advanced Android Wear ;)
 

More from Takahiro (Poly) Horikawa

The Land of Oz 20191109 Magic Leap x docomo meetup
The Land of Oz 20191109 Magic Leap x docomo meetupThe Land of Oz 20191109 Magic Leap x docomo meetup
The Land of Oz 20191109 Magic Leap x docomo meetupTakahiro (Poly) Horikawa
 
エニグマ暗号とは何だったのか
エニグマ暗号とは何だったのかエニグマ暗号とは何だったのか
エニグマ暗号とは何だったのかTakahiro (Poly) Horikawa
 
コンピュータービジョン最先端ガイド2 3.4ベクトルデータに対するカーネル法(SVM)
コンピュータービジョン最先端ガイド2 3.4ベクトルデータに対するカーネル法(SVM) コンピュータービジョン最先端ガイド2 3.4ベクトルデータに対するカーネル法(SVM)
コンピュータービジョン最先端ガイド2 3.4ベクトルデータに対するカーネル法(SVM) Takahiro (Poly) Horikawa
 
加速度センサーで円運動を検出する
加速度センサーで円運動を検出する加速度センサーで円運動を検出する
加速度センサーで円運動を検出するTakahiro (Poly) Horikawa
 
第10回Mozilla拡張機能勉強会-FireMobileSimulatorについて
第10回Mozilla拡張機能勉強会-FireMobileSimulatorについて第10回Mozilla拡張機能勉強会-FireMobileSimulatorについて
第10回Mozilla拡張機能勉強会-FireMobileSimulatorについてTakahiro (Poly) Horikawa
 

More from Takahiro (Poly) Horikawa (10)

The Land of Oz 20191109 Magic Leap x docomo meetup
The Land of Oz 20191109 Magic Leap x docomo meetupThe Land of Oz 20191109 Magic Leap x docomo meetup
The Land of Oz 20191109 Magic Leap x docomo meetup
 
生命を記述する数学
生命を記述する数学生命を記述する数学
生命を記述する数学
 
エニグマ暗号とは何だったのか
エニグマ暗号とは何だったのかエニグマ暗号とは何だったのか
エニグマ暗号とは何だったのか
 
コンピュータービジョン最先端ガイド2 3.4ベクトルデータに対するカーネル法(SVM)
コンピュータービジョン最先端ガイド2 3.4ベクトルデータに対するカーネル法(SVM) コンピュータービジョン最先端ガイド2 3.4ベクトルデータに対するカーネル法(SVM)
コンピュータービジョン最先端ガイド2 3.4ベクトルデータに対するカーネル法(SVM)
 
Android開発の基礎_20101218
Android開発の基礎_20101218Android開発の基礎_20101218
Android開発の基礎_20101218
 
加速度センサーで円運動を検出する
加速度センサーで円運動を検出する加速度センサーで円運動を検出する
加速度センサーで円運動を検出する
 
PRML chapter5
PRML chapter5PRML chapter5
PRML chapter5
 
PRML chapter7
PRML chapter7PRML chapter7
PRML chapter7
 
ESPer2008-FireMobileSimulatorについて
ESPer2008-FireMobileSimulatorについてESPer2008-FireMobileSimulatorについて
ESPer2008-FireMobileSimulatorについて
 
第10回Mozilla拡張機能勉強会-FireMobileSimulatorについて
第10回Mozilla拡張機能勉強会-FireMobileSimulatorについて第10回Mozilla拡張機能勉強会-FireMobileSimulatorについて
第10回Mozilla拡張機能勉強会-FireMobileSimulatorについて
 

Recently uploaded

OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 

Recently uploaded (20)

OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 

Android Wear Development

  • 1. Android Wear Development July 25, 2014 Takahiro Poly Horikawa
  • 2. Agenda • Android wear’s features and capabilities • How to develop? – Notification – Sending and syncing data • Development case study
  • 4. How it works? • Require android (>= 4.3) phone/tablet (referred as handheld) • Require “Android Wear” app on the handheld • Handheld and wearable communicate each other via Bluetooth (wearable itself does not connect to internet) Notifications
  • 5. What you can do? • Receive notifications and react them on the wearable • Control apps on the phone from the wearable • Run wearable specific app (e.g. compass, heart rate monitor) • Voice search and voice action etc…
  • 7. Cue card … Cue cards Voice Search and voice action
  • 8. Hardware Spec Samsung Gear Live LG G Watch Screen 1.63" 320×320 AMOLED display (278ppi) 1.65” 280×280 IPS LCD display (240ppi) OS Android 4.4W Android 4.4W CPU 1.2GHz Snapdragon 400 1.2GHz Snapdragon 400 RAM 512MBytes 512MBytes Storage 4GBytes 4GBytes Weight 59g 63g Thickness 8.9mm 9.95mm Battery 300mAh 400mAh
  • 9. Sensors (Samsung Gear Live) • MPL Rotation Vector (Invensense) • MPL Gravity (Invensense) • MPL Orientation (Invensense) • MPL Linear Accelration (Invensense) • MPU6515 Acceleration Sensor (Invensense) • MPU6515 Gyroscope Sensor (Invensense) • SAMSUNG Tilt Wake Sensor (Samsung Inc.) • SAMSUNG Significant Motion Sensor (Samsung Inc.) • SAMSUNG Game Rotation Vector (Samsung Inc.) • SAMSUNG Step Counter Sensor (Samsung Inc.) • SAMSUNG Step Detector Sensor (Samsung Inc.) • AK8963C Magnetic Sensor UnCalibrated (Asahi Kasei Microdevices) • AK8963C Magnetic field Sensor (Asahi Kasei Microdevices) • ADPD142 HRM Sensor Lib (ADI)
  • 10. Application packaging and publishing • When publishing to user, package a wearable app inside a handheld app • Wearable app will be installed on user’s wearable automatically when user install handheld app from Google Play Store • A handheld app has to have the same package name as a wearable app
  • 12. Notification • Add action • Add voice reply • Stacking notification • Add pages
  • 13. Add action Intent intent = new Intent(context, NotificationLandingActivity.class); PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, 0); Notification n = new NotificationCompat.Builder(context) .setContentTitle("新着メッセージがあります") .setContentText("xxさんからメッセージが届いています") .setSmallIcon(R.drawable.ic_launcher) .setContentIntent(pIntent) .addAction(R.drawable.ic_launcher, "返信", pIntent) .addAction(R.drawable.ic_launcher, "転送", pIntent) .build(); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); notificationManager.notify(0, n); NotificationActivity.java (Handheld)
  • 14. Add voice reply String replyLabel = ”会議に参加しますか?"; String[] replyChoices = {"はい", "いいえ”}; RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) .setLabel(replyLabel) .setChoices(replyChoices) .build(); Intent replyIntent = new Intent(ctx, VoiceReceiverActivity.class); PendingIntent replyPendingIntent = PendingIntent.getActivity(ctx, 0, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.i c_launcher, "返信", replyPendingIntent) .addRemoteInput(remoteInput) .build(); Notification notification = new NotificationCompat.Builder(ctx) .extend(new NotificationCompat.WearableExtender().addActi on(action)).build(); NotificationManagerCompat manager = NotificationManagerCompat.from(ctx); manager.notify(200, notification); NotificationActivity.java (Handheld) Specify the action only available on wearableKey to receive voice text in the target Activity
  • 15. Receive voice input public class VoiceReceiverActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_voice_input_receiver); Bundle remoteInput = RemoteInput.getResultsFromIntent(getIntent()); CharSequence message = remoteInput.getCharSequence(NotificationActivity.EXTRA_VOICE_REPLY); ((TextView) findViewById(R.id.message)).setText(String.format("音声入 力メッセージは「%s」です。", message)); } } VoiceReceiverActivity.java (Handheld)
  • 16. Stacking Notification NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); Notification card1 = new NotificationCompat.Builder(context) .setContentText("何してますか?") .setGroup(GROUP_KEY).setSortKey("0”).build(); notificationManager.notify(101, card1); Notification card2 = new NotificationCompat.Builder(context) .setContentText("手伝ってもらってもいいですか?") .setGroup(GROUP_KEY).setSortKey("1”).build(); notificationManager.notify(102, card2); Notification summary = new NotificationCompat.Builder(context) .setContentTitle("新着メッセージ2件") .setGroup(GROUP_KEY).setGroupSummary(true).build(); notificationManager.notify(100, summary); NotificationActivity.java (Handheld)
  • 17. Add pages Notification page = new NotificationCompat.Builder(context) .setStyle(new NotificationCompat.BigTextStyle().bigText("メンチカツ定食 $7.99")) .build(); Notification notification = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle("xxレストラン通信") .setContentText("本日の日替わりランチ") .extend(new NotificationCompat.WearableExtender().addPage(page)) .build(); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); notificationManager.notify(300, notification); NotificationActivity.java (Handheld)
  • 18. Notification gotcha • Notification from the handheld can only open an activity on the handheld • To open/embed a custom activity on the wearable, you need to send notification from the wearable. • Open a custom activity • Embed a custom activity Custom Activity
  • 19. Send notification to open an activity on the wearable Intent viewIntent = new Intent(context, WatchActivity.class); PendingIntent pendingViewIntent = PendingIntent.getActivity(context, 0, viewIntent, 0); Notification notification = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle("Wearableから送信") .setContentText("Wearableから送信したNotificationです。") .addAction(R.drawable.ic_launcher, "Open", pendingViewIntent) .setLocalOnly(true) .extend(new NotificationCompat.WearableExtender().setContentAction(0).setHintHideIcon(true)) .build(); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); notificationManager.notify(3000, notification); WatchActivity.java (Wearable) Specify the default action to be triggered when user tap the notification
  • 20. Send notification embedding an activity on the wearable Intent viewIntent = new Intent(context, NotificationEmbeddedActivity.class); PendingIntent pendingViewIntent = PendingIntent.getActivity(context, 0, viewIntent, 0); Notification notification = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle("Wearableから送信") .setContentText("Wearableから送信したNotificationです。") .setLocalOnly(true) .extend(new NotificationCompat.WearableExtender().setDisplayIntent(pendingViewIntent)) .build(); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); notificationManager.notify(4000, notification); WatchActivity.java (Wearable) Custom Activity Specify the Pending Intent of activity to be embedded in the notification
  • 21. Sending and syncing data • Message API – Fire and forgot, one way request – You can send just a string – Use case example • Control media player from the wearable • Data API – Sync data between the handheld and wearable – Payload is a byte array (100KB per item), but you can use map interface to access data – Use case example • Send Photo preview from the handheld to wearable
  • 22. Connect Google Api Client private GoogleApiClient mGoogleApiClient; @Override protected void onCreate(Bundle savedInstanceState) { mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Wearable.API) .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() { @Override public void onConnected(Bundle bundle) { Log.d(TAG, "Google Api Client connected"); } @Override public void onConnectionSuspended(int i) { } }).build(); mGoogleApiClient.connect(); } DataActivity.java (Handheld)
  • 23. Message API private void sendMessageToStartActivity() { Collection<String> nodes = getNodes(); for (String node : nodes) { Wearable.MessageApi.sendMessage(mGoogleApiClient, node, START_ACTIVITY_PATH, null).await(); } } private Collection<String> getNodes() { HashSet<String> results = new HashSet<String>(); NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await(); for (Node node : nodes.getNodes()) { results.add(node.getId()); } return results; } DataActivity.java (Handheld)
  • 24. Message API public class DataLayerListenerService extends WearableListenerService { @Override public void onMessageReceived(MessageEvent messageEvent) { if (START_ACTIVITY_PATH.equals(messageEvent.getPath())) { Intent intent = new Intent(this, WatchActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); return; } } } <service android:name=".DataLayerListenerService"> <intent-filter> <action android:name="com.google.android.gms.wearable.BIND_LISTENER" /> </intent-filter> </service> AndroidManifest.xml (Wearable) DataLayerListenerService.java (Wearable)
  • 25. Data API send data from handheld int count = 0; private void sendCount() { PutDataMapRequest dataMap = PutDataMapRequest.create(COUNT_PATH); dataMap.getDataMap().putInt(COUNT_KEY, ++count); PutDataRequest request = dataMap.asPutDataRequest(); PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi .putDataItem(mGoogleApiClient, request); pendingResult.setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(DataApi.DataItemResult dataItemResult) { Log.d(TAG, "count updated:" + count); } }); } DataActivity.java (Handheld)
  • 26. Data API detect data change on wearable public class DataLayerListenerService extends WearableListenerService { @Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent event : dataEvents) { DataItem dataItem = event.getDataItem(); if (COUNT_PATH.equals(dataItem.getUri().getPath())) { DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap(); int count = dataMap.getInt(COUNT_KEY); …. } } } } DataLayerListenerService.java (Wearable)
  • 27. Data API access to the existing data private void restoreCurrentCount() { String localNodeId = getLocalNodeId(); Uri uri = new Uri.Builder().scheme(PutDataRequest.WEAR_URI_SCHEME).authority(localNodeId).path(COUNT_PATH).buil d(); Wearable.DataApi.getDataItem(mGoogleApiClient, uri).setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(DataApi.DataItemResult dataItemResult) { DataItem dataItem = dataItemResult.getDataItem(); if (dataItem != null) { DataMap dataMap = DataMapItem.fromDataItem(dataItemResult.getDataItem()).getDataMap(); count = dataMap.getInt(COUNT_KEY); } } }); } private String getLocalNodeId() { NodeApi.GetLocalNodeResult nodeResult = Wearable.NodeApi.getLocalNode(mGoogleApiClient).await(); return nodeResult.getNode().getId(); } DataActivity.java (Handheld) The uri of data is wear://<NODE_ID>/<PAT H> Node ID is required to send message
  • 28. Combination (1) • Update embedded activity in notification from the handheld Data API Notification with DisplayIntent Data API Notification with DisplayIntent Data API Notification with DisplayIntent Example: Google Map navigation on wearable
  • 29. Combination (2) • Send notification from handheld to wearable to open a custom activity on wearable Data API Notification Tap to open Custom Activity Message API Example: Remote shutter for Google Camera app
  • 31. Draw Watch for Android Wear • https://play.google.com/store/apps/details?id =com.polysfactory.drawwatch
  • 33. Random stuff I leaned • Prevent default behavior of wearable (right swipe to dismiss app) – Place close menu on the second screen, but it is very confusing • Starting app from cue card is a little bit annoying, it’s better to use notification • Using Message API to share bitmap on the handheld works great
  • 34. All sample code is available at github https://github.com/thorikawa/AndroidWearSampleJp