Download - 3009 system 2 account mobiiii kxkds
![Page 1: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/1.jpg)
Ok Google, o que é
+Nelson Glauber
?
@nglauber nglauber.blogspot.com
![Page 2: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/2.jpg)
Android Wear estende a plataforma Android para uma nova geração de dispositivos, com uma usabilidade desenhada especificamente para os wearables.
![Page 3: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/3.jpg)
Serve para que?
125 vezes ao dia em média!!!
Vida realPega o telefone
Devagando no telefone
Mais tempo para interagir com as pessoas à sua volta
![Page 4: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/4.jpg)
UI baseada em um stream de cards
![Page 5: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/5.jpg)
Comandos de voz
![Page 6: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/6.jpg)
Princípios de UI
![Page 7: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/7.jpg)
Lançadas automaticamente
Glanceable
Sugestão e demanda
![Page 8: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/8.jpg)
Não interrompa o usuário
Grandes áreas de toque
Micro-interações
![Page 9: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/9.jpg)
O que precisamos?
![Page 10: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/10.jpg)
O que precisamos?
Android Studio 0.8
Google Play Services
Android Wear Device
![Page 11: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/11.jpg)
LG G Watch
280x280, 512MB, 4GB, 400mAh Qualcomm Snapdragon 400 - 1.2Ghz
Acelerômetro, Gyro, Compass
Samsung Gear Live
320x320, 512MB, 4GB, 300mAh Qualcom Snapdragon 400 - 1.2Ghz
Acelerômetro, Gyro, Compass e Heart
![Page 12: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/12.jpg)
Motorola Moto 360
320x290, 512MB, 4GB, 320mAh TI OMAP 3 - 1.2Ghz Pedometer e Heart
LG G Watch R
320x320, 512MB, 4GB, 410mAh Qualcomm Snapdragon - 1.2Ghz
Acelerometer, Gyro, Compass, Barometer e Heart
![Page 13: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/13.jpg)
adb -d forward tcp:5601 tcp:5601
![Page 14: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/14.jpg)
Android Wear Companion
![Page 15: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/15.jpg)
Notificações Sincronizadas
Comandos de Voz
Aplicações Wear
Envio e sincronização de dados
APIs
![Page 16: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/16.jpg)
Notificações Sincronizadas
Comandos de Voz
Aplicações Wear
Envio e sincronização de dados
APIs
![Page 17: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/17.jpg)
Notificações
Imagem de Background
Ícone da aplicação
Título
Texto
![Page 18: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/18.jpg)
Notificações simples
![Page 19: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/19.jpg)
Notificações simples
PendingIntent pit = PendingIntent.getActivity( this, 0, new Intent(this, MainMobileActivity.class), 0); !Notification notification = new NotificationCompat.Builder(this) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle("Notificação Simples") .setContentText("Texto da notificação") .setSmallIcon(R.drawable.ic_notificacao) .setLargeIcon(largeIcon) .setContentIntent(pit) .setAutoCancel(true) .build(); NotificationManagerCompat.from(this).notify(1000, notification);
![Page 20: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/20.jpg)
Notificações com ação
![Page 21: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/21.jpg)
Notificações com ação
Intent itAgenda = new Intent(Intent.ACTION_VIEW); itAgenda.setData( Uri.parse("content://com.android.calendar/time")); PendingIntent pitAcao = PendingIntent.getActivity(this, 0, itAgenda, 0); !Notification notification = new NotificationCompat.Builder(this) // demais chamadas da notificação simples .addAction( new NotificationCompat.Action( R.drawable.ic_agenda, "Agenda", pitAcao)) .build();
![Page 22: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/22.jpg)
Notificações em pilha
![Page 23: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/23.jpg)
Notificações em pilha
static int idNotificacao = 0; !Notification notification = new NotificationCompat.Builder(this) // demais chamadas da notificação simples .setContentTitle("Notificação Simples "+ ++idNotificacao) .setGroup("meuGrupo") .build();
![Page 24: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/24.jpg)
NotificationCompat.WearableExtender extensionWear = new NotificationCompat.WearableExtender() .setBackground(largeIcon); !NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle() .setBigContentTitle("Notificação em Pilha") .addLine("Várias mensagens não lidas") .setSummaryText("Resumo"); !Notification notificationSummary = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_notificacao) .setStyle(inboxStyle) .extend(extensionWear) .setGroup("meuGrupo") .setGroupSummary(true) .build(); !NotificationManagerCompat nm = NotificationManagerCompat.from(this); !nm.notify(idNotificacao, notification); nm.notify(1000, notificationSummary);
![Page 25: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/25.jpg)
Notificações com páginas
![Page 26: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/26.jpg)
NotificationCompat.Builder notificationPage1 = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_notificacao) .setContentTitle("Primeira Página") .setContentText("Essa é a primeira página") .setLargeIcon(largeIcon) .setAutoCancel(true) .setContentIntent(pit) .setDefaults(NotificationCompat.DEFAULT_ALL); !Notification notificationPage2 = new NotificationCompat.Builder(this) .setStyle(new NotificationCompat.BigTextStyle() .setBigContentTitle("Segunda página") .bigText("Essa é a segunda página")) .build(); !Notification notificationWithTwoPages = new NotificationCompat.WearableExtender() .addPage(notificationPage2) .extend(notificationPage1) .build(); !NotificationManagerCompat nm = NotificationManagerCompat.from(this); nm.notify(1000, notificationWithTwoPages);
![Page 27: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/27.jpg)
Notificações Sincronizadas
Comandos de Voz
Aplicações Wear
Envio e sincronização de dados
APIs
![Page 28: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/28.jpg)
Respondendo com voz
![Page 29: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/29.jpg)
Respondendo com vozRemoteInput remoteInput = new RemoteInput.Builder(DetalheActivity.EXTRA_RESPOSTA_VOZ) .setLabel("Diga a resposta") .build(); !NotificationCompat.Action action = new NotificationCompat.Action.Builder( R.drawable.ic_responder, "Responder", pit) .addRemoteInput(remoteInput) .build(); !NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender() .addAction(action); !Notification notification = new NotificationCompat.Builder(this) // demais chamadas da notificação simples .extend(wearableExtender) .build();
![Page 30: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/30.jpg)
Respondendo com voz
Bundle remoteInput = remoteInput.getResultsFromIntent(getIntent()); !String voz = remoteInput.getCharSequence(EXTRA_RESPOSTA_VOZ).toString();
![Page 31: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/31.jpg)
Comandos de voz
Call a car/taxi Take a note
Set alarm Set timer
Start/stop bike Start/stop a run
Start/stop workout Show heart rate
Show step count App Name :)
https://developer.android.com/training/wearables/apps/voice.html
![Page 32: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/32.jpg)
Notificações Sincronizadas
Comandos de Voz
Aplicações Wear
Envio e sincronização de dados
APIs
![Page 33: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/33.jpg)
Aplicações Wear
MinhaApp
MobileAPK WearAPK
![Page 34: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/34.jpg)
MinhaApp
![Page 35: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/35.jpg)
WatchViewStub BoxInsetLayout WearableListView CircledImageView GridViewPager GridPagerAdapter FragmentGridPagerAdapter CardFragment ConfirmationActivity DismissOverlayView
Componentesandroid.support.wearable.view.
![Page 36: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/36.jpg)
<android.support.wearable.view.WatchViewStub xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/watch_view_stub" android:layout_width="match_parent" android:layout_height="match_parent" app:rectLayout="@layout/rect_activity_main_wear" app:roundLayout="@layout/round_activity_main_wear" tools:context=".MainWearActivity" tools:deviceIds="wear"> </android.support.wearable.view.WatchViewStub>
res/layout/rect_activity_main_wear.xml
res/layout/round_activity_main_wear.xml
![Page 37: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/37.jpg)
WearableListView
WearableListView WearableListView.Item WearableListView.ClickListener RecyclerView.Adapter CircledImageView
![Page 38: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/38.jpg)
GridViewPager
GridViewPager GridPagerAdapter FragmentGridPagerAdapter CardFragment CardFrame
![Page 39: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/39.jpg)
ConfirmationActivity<activity android:name= "android.support.wearable.activity.ConfirmationActivity"/>
Intent it = new Intent(context, ConfirmationActivity.class); it.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE, ConfirmationActivity.OPEN_ON_PHONE_ANIMATION); startActivity(it);
![Page 40: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/40.jpg)
<style name="AppTheme" parent="@android:style/Theme.DeviceDefault"> <item name="android:windowSwipeToDismiss">false</item> </style>
<android.support.wearable.view.DismissOverlayView android:id="@+id/dismiss" android:layout_width="match_parent" android:layout_height="match_parent"/>
DismissOverlayView
![Page 41: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/41.jpg)
Notificações Sincronizadas
Comandos de Voz
Aplicações Wear
Envio e sincronização de dados
APIs
![Page 42: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/42.jpg)
Comunicação Mobile/Wear
MinhaApp
MobileAPK WearAPK
![Page 43: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/43.jpg)
Google Play Services
GoogleApiClient googleApiClient = new GoogleApiClient.Builder(context) .addApi(Wearable.API) .addConnectionCallbacks(cc) .addOnConnectionFailedListener(cfl) .build();
compile 'com.google.android.gms:play-services:5.0.89'
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
![Page 44: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/44.jpg)
Node API
Message API
Data API
![Page 45: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/45.jpg)
Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).setResultCallback( new ResultCallback<NodeApi.GetConnectedNodesResult>() { @Override public void onResult(NodeApi.GetConnectedNodesResult result) { Node node = result.getNodes().get(0); } });
Wearable.NodeApi.addListener(mGoogleApiClient, new NodeApi.NodeListener() { @Override public void onPeerConnected(Node node) { } @Override public void onPeerDisconnected(Node node) { } });
Node API
![Page 46: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/46.jpg)
Wearable.MessageApi.sendMessage(mGoogleApiClient, node.getId(), "/navegacao", new byte[]{ 1, 2, 3 } );
Message API
Wearable.MessageApi.addListener(mGoogleApiClient, new MessageApi.MessageListener() { @Override public void onMessageReceived(MessageEvent messageEvent) { String remetente = messageEvent.getSourceNodeId(); String caminho = messageEvent.getPath(); byte[] dados = messageEvent.getData(); } });
![Page 47: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/47.jpg)
PutDataMapRequest putDataMapRequest = PutDataMapRequest.create("/dados"); DataMap dataMap = putDataMapRequest.getDataMap(); dataMap.putInt("numero", 1); dataMap.putString("nome", "Glauber"); !Wearable.DataApi.putDataItem( mGoogleApiClient, putDataMapRequest.asPutDataRequest());
Data API
![Page 48: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/48.jpg)
Wearable.DataApi.addListener(mGoogleApiClient, new DataApi.DataListener() { @Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent dataEvent : dataEvents){ if (dataEvent.getType() == DataEvent.TYPE_CHANGED){ DataMapItem dataMapItem = DataMapItem.fromDataItem(dataEvent.getDataItem()); Uri uri = dataMapItem.getUri(); if (uri.getPath().equals("/dados")) { DataMap dataMap = dataMapItem.getDataMap(); int numero = dataMap.getInt("numero"); String nome = dataMap.getString("nome"); } } } }
});
Data API
![Page 49: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/49.jpg)
WearableListenerService extends Service implements NodeApi.NodeListener, MessageApi.MessageListener, DataApi.DataListener
Node API
Message API
Data API
<service android:name="ngvl.android.devfest.MeuService"> <intent-filter> <action android:name="com.google.android.gms.wearable.BIND_LISTENER" /> </intent-filter> </service>
![Page 50: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/50.jpg)
![Page 51: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/51.jpg)
Dúvidas?
![Page 52: 3009 system 2 account mobiiii kxkds](https://reader034.vdocuments.pub/reader034/viewer/2022042601/5f73e3bc07df10171d3b0c8b/html5/thumbnails/52.jpg)
Nelson Glauber@nglauber
+NelsonGlauber nglauber.blogspot.com