Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Building an Android Wear app
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Andy Dyer
August 12, 2015
Programming
98
0
Share
Building an Android Wear app
A brief talk about building an Android Wear app presented at one of our weekly tech talks.
Andy Dyer
August 12, 2015
More Decks by Andy Dyer
See All by Andy Dyer
AppCraft: Faster Than a Speeding Release Train
abdyer
1
350
Multiple Developers, One App: How to Not Break Everything
abdyer
0
370
Things That Suck About Android Development
abdyer
0
600
MCE2015 - Automated Testing for Modern Android Applications
abdyer
0
1.4k
BABBQ5 - Automated Testing for Modern Android Applications
abdyer
14
3.8k
Other Decks in Programming
See All in Programming
煩雑なSkills管理をSoC(関心の分離)により解決する――関心を分離し、プロンプトを部品として育てるためのOSSを作った話 / Solving Complex Skills Management Through SoC (Separation of Concerns)
nrslib
4
1.1k
アクセシビリティ試験の"その後"を仕組み化する
yuuumiravy
1
180
PCOVから学ぶコードカバレッジ #phpcon_odawara
o0h
PRO
0
280
AIと共に生きる技術選定 2026
sgash708
0
110
10年分の技術的負債、完済へ ― Claude Code主導のAI駆動開発でスポーツブルを丸ごとリプレイスした話
takuya_houshima
0
2.7k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
480
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
4
1.3k
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
120
書籍「ユーザーストーリーマッピング」が私のバイブル
asumikam
4
450
Don't Prompt Harder, Structure Better
kitasuke
0
790
Cache-moi si tu peux : patterns et pièges du cache en production - Devoxx France 2026 - Conférence
slecache
0
320
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
110
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
280
Color Theory Basics | Prateek | Gurzu
gurzu
0
300
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
10k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
How to Ace a Technical Interview
jacobian
281
24k
Facilitating Awesome Meetings
lara
57
6.8k
What's in a price? How to price your products and services
michaelherold
247
13k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
The Invisible Side of Design
smashingmag
303
52k
Rails Girls Zürich Keynote
gr2m
96
14k
Transcript
Building an Android Wear app
Anatomy of an Android Wear app 4 Wearable app 4
Mobile app, with wearable app packaged inside 4 Communicate via notifications and/or Google Play Services APIs
Never Gonna GIF You Up
Loading a random GIF on the watch 1. UI library
for displaying GIFs 2. Request random GIF from Giphy API 3. Make API request, update view
Loading a random GIF on the watch 1. UI library
for displaying GIFs 2. Request random GIF from Giphy API 3. Make API request, update view Most wearables don't have internet...yet
Wearable app
Wearable app 1. UI library for displaying GIFs 2. Request
GIF from mobile app 3. Listen for data change from phone 4. Update view
Request GIF from mobile app Set<Node> nodes = Wearable.CapabilityApi .getCapability(googleApiClient,
"gif_me", CapabilityApi.FILTER_REACHABLE) .await() .getCapability() .getNodes(); if (!nodes.isEmpty()) { for (Node node : nodes) { Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), "gif/random", null).await(); } }
Listen for data changes @Override public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED) { DataItem item = event.getDataItem(); if (item.getUri().getPath().compareTo("/image") == 0) { Asset asset = DataMapItem.fromDataItem(item).getDataMap().get("random_gif"); // Do something with asset } } } }
Mobile app
Mobile app 1. WearableListenerService to listen for GIF requests 2.
Request random GIF from Giphy API 3. Push file bytes to wearable via Data API
Registering a WearableListenerService - AndroidManifest.xml <service android:name=".GifRequestWearableListenerService" tools:ignore="ExportedService" > <intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" /> </intent-filter> </service>
Registering a WearableListenerService: res/values/wear.xml <resources> <string-array name="android_wear_capabilities"> <item>gif_me</item> </string-array> </resources>
WearableListenerService public class GifRequestWearableListenerService extends WearableListenerService { @Override public void
onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals("gif/random")) { bytes[] imageBytes = getRandomGif(); Asset asset = Asset.createFromBytes(imageBytes) pushAsset(asset); } } private void pushAsset(Asset asset) { PutDataMapRequest request = PutDataMapRequest.create("/image"); request.getDataMap().putAsset("random_gif", asset); Wearable.DataApi.putDataItem(googleApiClient, request.asPutDataRequest()); } }
Achtung! 4 Enable developer options and debugging on the wearable
4 Packaged wearable apps aren't automatically deployed for debug builds 4 Deploy the right app to the right device 4 It's difficult to debug end-to-end. Focus on one end at a time.
Weird stuff 4 Retrolambda doesn't currently work with Android Wear.
It seems to break the packaging of the wearable app into the mobile app.