63
Android Wear Heider Lopes

Android Wear: Expandindo as funcionalidades do seu Android

Embed Size (px)

DESCRIPTION

Palestra realizada no Android Meetup #19 organizado pelo GDG SP.

Citation preview

  • 1. Android WearHeider Lopes

2. Quem sou? Desenvolvedor na B2W Digital Integrante do Things Hacker Team Palestrante Mantenedor do site: heiderlopes.com.br 3. Eu nas Redes Sociaistwitter.com/heiderlopeslinkedin.com/pub/heider-lopesgithub.com/heiderlopesslideshare.net/heiderlopes 4. Agenda O que Android Wear? O que so dispositivos wareables? Como funciona? Formas de integrao Dicas de desenvolvimento Demos 5. O que o Android Wear? uma plataforma desenvolvida pelo Googlepara dispositivos wareables. 6. O que so wareables? Pequenos dispositivos poderosos, usados nocorpo Fornecem informaes teis quando vocmais precisa Respostas inteligentes a perguntas faladas Ferramentas para ajudar alcanar objetivosfitness 7. O que o Android Wear?Atualmente utilizado por relgiosSamsung Gear LiveLG G Watch Moto 360 8. O que o Android Wear?ZenWatchSony SmartWatch 3 9. O que o Android Wear?Pode expandir para outros wearable comosapatos, caneta, correntes, brincos, entreoutros. 10. Vdeo de Introduo 11. Imaginem 12. J temos aplicativos para isso? 13. Como funciona?Conecta via Bluetooth com dispositivosque rodam Android 4.3 ou superior 14. Desenvolvimento para Android Wear 15. Desenvolvimento para Android Wear 16. CompatibilidadeSo encontradas via Google Play Services eno Android Support Library 17. Formas de Integrao 18. Notificaes 19. Exemplo de Notificacaoint notificationId = 001;// Build intent for notification contentIntent viewIntent = new Intent(this, ViewEventActivity.class);viewIntent.putExtra(EXTRA_EVENT_ID, eventId);PendingIntent viewPendingIntent =PendingIntent.getActivity(this, 0, viewIntent, 0);NotificationCompat.Builder notificationBuilder =new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_event).setContentTitle(eventTitle).setContentText(eventLocation).setContentIntent(viewPendingIntent);// Get an instance of the NotificationManager serviceNotificationManagerCompat notificationManager =NotificationManagerCompat.from(this);// Build the notification and issues it with notification manager.notificationManager.notify(notificationId, notificationBuilder.build()); 20. Add Action Buttons 21. Exemplo de Action button// Build an intent for an action to view a mapIntent mapIntent = new Intent(Intent.ACTION_VIEW);Uri geoUri = Uri.parse("geo:0,0?q=" + Uri.encode(location));mapIntent.setData(geoUri);PendingIntent mapPendingIntent =PendingIntent.getActivity(this, 0, mapIntent, 0);NotificationCompat.Builder notificationBuilder =new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_event).setContentTitle(eventTitle).setContentText(eventLocation).setContentIntent(viewPendingIntent).addAction(R.drawable.ic_map,getString(R.string.map), mapPendingIntent); 22. Big View 23. Big ViewBigTextStyle bigStyle = new NotificationCompat.BigTextStyle();bigStyle.bigText(eventDescription);NotificationCompat.Builder notificationBuilder =new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_event).setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notif_background)).setContentTitle(eventTitle).setContentText(eventLocation).setContentIntent(viewPendingIntent).addAction(R.drawable.ic_map,getString(R.string.map), mapPendingIntent).setStyle(bigStyle); 24. Adding Pages to a Notification 25. Pages to a NotificationNotificationCompat.Builder notificationBuilder =new NotificationCompat.Builder(this).setSmallIcon(R.drawable.new_message).setContentTitle("Page 1").setContentText("Short message").setContentIntent(viewPendingIntent);// Create a big text style for the second pageBigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle();secondPageStyle.setBigContentTitle("Page 2").bigText("A lot of text...");// Create second page notificationNotification secondPageNotification =new NotificationCompat.Builder(this).setStyle(secondPageStyle).build();// Add second page with wearable extender and extend the main notificationNotification twoPageNotification =new WearableExtender().addPage(secondPageNotification).extend(notificationBuilder).build();// Issue the notificationnotificationManager =NotificationManagerCompat.from(this);notificationManager.notify(notificationId, twoPageNotification); 26. Empilhamento de Notificaes 27. Stacking Notificationsfinal static String GROUP_KEY_EMAILS = "group_key_emails";// Build the notification, setting the group appropriatelyNotification notif = new NotificationCompat.Builder(mContext).setContentTitle("New mail from " + sender1).setContentText(subject1).setSmallIcon(R.drawable.new_mail);.setGroup(GROUP_KEY_EMAILS).build();// Issue the notificationNotificationManagerCompat notificationManager =NotificationManagerCompat.from(this);notificationManager.notify(notificationId1, notif);Notification notif2 = new NotificationCompat.Builder(mContext).setContentTitle("New mail from " + sender2).setContentText(subject2).setSmallIcon(R.drawable.new_mail);.setGroup(GROUP_KEY_EMAILS).build(); 28. Recebimento de voz 29. SimNoTalvez 30. public static final EXTRA_VOICE_REPLY = "extra_voice_reply";...String replyLabel = getResources().getString(R.string.reply_label);String[] replyChoices = getResources().getStringArray(R.array.reply_choices);RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel(replyLabel).setChoices(replyChoices).build(); 31. // Create an intent for the reply actionIntent replyIntent = new Intent(this, ReplyActivity.class);PendingIntent replyPendingIntent =PendingIntent.getActivity(this, 0, replyIntent,PendingIntent.FLAG_UPDATE_CURRENT);// Create the reply action and add the remote inputNotificationCompat.Action action =new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon,getString(R.string.label, replyPendingIntent)).addRemoteInput(remoteInput).build();// Build the notification and add the action via WearableExtenderNotification notification =new NotificationCompat.Builder(mContext).setSmallIcon(R.drawable.ic_message).setContentTitle(getString(R.string.title)).setContentText(getString(R.string.content)).extend(new WearableExtender().addAction(action)).build();// Issue the notificationNotificationManagerCompat notificationManager =NotificationManagerCompat.from(mContext);notificationManager.notify(notificationId, notification); 32. private CharSequence getMessageText(Intent intent) {Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);if (remoteInput != null) {return remoteInput.getCharSequence(EXTRA_VOICE_REPLY);}}return null;} 33. Comando de VozPodemos recuperar informaes e executartarefas no wearable e no dispositivo porttilemparelhado 34. Envio de TextosEnvio de textos, mensagens instantneas e e-mails("enviar Heider Lopes mensagemTestando o Android Wear", e em seguida, falar asua mensagem). 35. Obter respostasObter respostas a essas questes importantesda vida, como: "ser que vai chover hoje tarde?" 36. Obter direesObter direes por exemplo: "como chegar naRua Funchal?".So disparados Cards no Weareable e vibra nahora de fazer uma curva 37. Criar lembretesCriar lembrate para um determinado perodo detempo ou Quando.O Android Wear detecta que voc est em umlocal especfico e te ajuda a lembrar o que tem afazer.("lembre-me de enviar e-mail quando chegar notrabalho.") 38. Criar notasTomar notas usando o Google Keep ("tomarnota, terminar a apresentao de Android Wearpara o GDG") 39. Abrir aplicativo no Dispostivo PareadoAbrir aplicativo no Smartphone ou Tablet("Abrir Facebook") 40. Criando Apps Wearable 41. APIS No Suportadas android.webkit android.print android.appwidget android.hardware.usb 42. Enviar Dados 43. Debugando pelo BluetoothOs passos podem ser acessados atravs do sitedo desenvolvedor:https://developer.android.com/training/wearables/apps/bt-debugging.html 44. Configurar Dispositivo para Debug 45. Habilitando no Mobile 46. Habilitando no Wear 47. Configurando a sesso de Debugadb -s localhost:4444 adb -e logcatadb -e shelllConecte seu mobile com a mquina atravs da USBadb forward tcp:4444 localabstract:/adb-hub; adb connect localhost:4444 48. Dicas de Desenvolvimento 49. Dicas de DesenvolvimentoManter questionando como voc usaria umrelgio tradicional. 50. Dicas de DesenvolvimentoPortanto, uma grande parte da concepo deum aplicativo bem sucedido ser fcil de usar. 51. Dicas de DesenvolvimentoSuas cartas de notificao s deve exibir umanica pea de informao. 52. Dicas de DesenvolvimentoSe voc precisa de mais informaes, usepginas adicionais ao invs de tentar espremermais informaes em um nico carto. 53. Manter texto a um mnimoSeu carto de notificao deve conter apenaspalavras e frases curtas, e no frasescompletas. 54. Manter texto a um mnimoUm truque para manter o texto a um mnimo comunicar cada pedao de informao atravsde um cone e valor. 55. Fazer uso de imagens de fundoA utilizao de imagens de fundo serve parafornecer formas diferentes de notificaes paraseu aplicativo. 56. Obrigado pela participao!!!Confira mais novidade no QRCode acima