Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kitt I need you Buddy (Señores que le hablan a ...

Karumi
June 21, 2016

Kitt I need you Buddy (Señores que le hablan a la muñeca)

An introductory talk about Android Wear and Android Auto. We show how these APIs work and we can use them connected to talk with your car.

Karumi

June 21, 2016
Tweet

More Decks by Karumi

Other Decks in Technology

Transcript

  1. K.I.T.T. I need you buddy (Señores que le hablan a

    la muñeca) Jorge Juan Barroso Carmona Android Expert @flipper83 [email protected]
  2. Previous Notifications NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_event) .setContentTitle(eventTitle) .setContentText(eventLocation)

    .addAction(R.drawable.ic_map, getString(R.string.map), mapPendingIntent);; NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); manager. notificationManager.notify(notificationId, notificationBuilder.build());
  3. Pages // Create second page notification Notification secondPageNotification = new

    NotificationCompat.Builder(this) .setStyle(secondPageStyle) .build(); // Extend the notification builder with the second page Notification notification = notificationBuilder .extend(new NotificationCompat.WearableExtender() .addPage(secondPageNotification)) .build();
  4. Stack Notification notif2 = new NotificationCompat.Builder(mContext) .setContentTitle("New mail from "

    + sender2) .setContentText(subject2) .setSmallIcon(R.drawable.new_mail) .setGroup(GROUP_KEY_EMAILS) .build();
  5. Stack Notification summaryNotification = new NotificationCompat.Builder(mContext) .setStyle(new NotificationCompat.InboxStyle() .addLine("Alex Faaborg

    Check this out") .addLine("Jeff Chang Launch Party") .setBigContentTitle("2 new messages") .setSummaryText("[email protected]")) .setGroup(GROUP_KEY_EMAILS) .setGroupSummary(true) .build();
  6. Connecting with my phone addConnectionCallbacks DataItem —> Bundle with notification

    Wearable.MessageApi.sendMessage —> onMessageReceived WearableListenerService
  7. Ok Google, Start K.I.T.T <activity android:name="com.karumi.kittwear.WearMainActivity" android:label="kitt"> <intent-filter> <action android:name="android.intent.action.MAIN"/>

    <category android:name = "android.intent.category.LAUNCHER"/> </intent-filter> </activity> Spanish word for ‘start’ is Iniciar o abrir…
  8. Ok Google, Call a car <activity android:name="com.karumi.kittwear.WearMainActivity" android:label="kitt"> <intent-filter> <action

    android:name = “com.google.android.gms.actions. RESERVE_TAXI_RESERVATION" /> <category android:name = "android.intent.category.DEFAULT" /> </intent-filter> </activity> Spanish word for ‘call a car’ is ???
  9. Some voice command are not well documented Preset commands are

    define on the Android Wear documentation Documentation for spanish command does not exist. Trial and error.
  10. Free blah blah blah private void displaySpeechRecognizer() { Intent intent

    = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra (RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); startActivityForResult(intent, SPEECH_REQUEST_CODE); }
  11. @Override protected void onActivityResult (int requestCode, int resultCode,Intent data) {

    if (requestCode == SPEECH_REQUEST_CODE && resultCode == RESULT_OK) { List<String> results = data.getStringArrayListExtra( RecognizerIntent.EXTRA_RESULTS); String spokenText = results.get(0); //TODO Do something with spokenText } super.onActivityResult(requestCode, resultCode, data); }
  12. @Override protected void onActivityResult (int requestCode, int resultCode,Intent data) {

    if (requestCode == SPEECH_REQUEST_CODE && resultCode == RESULT_OK) { List<String> results = data.getStringArrayListExtra( RecognizerIntent.EXTRA_RESULTS); String spokenText = results.get(0); //TODO Do something with spokenText } super.onActivityResult(requestCode, resultCode, data); }
  13. <application> ... <receiver android:name=".MyMessageReadReceiver"> <intent-filter> <action android:name=“com.myapp.messagingservice. ACTION_MESSAGE_HEARD"/> </intent-filter> </receiver>

    <receiver android:name=".MyMessageReplyReceiver"> <intent-filter> <action android:name=“com.myapp.messagingservice. ACTION_MESSAGE_REPLY"/> </intent-filter> </receiver> ... </application> Messaging
  14. // Build a RemoteInput for receiving voice input in a

    Car // Notification RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) .setLabel(getApplicationContext().getString(R.string.not ification_reply)) .build(); // Create an unread conversation object to organize a group of messages from a particular sender. UnreadConversation.Builder unreadConvBuilder = new UnreadConversation.Builder(participantName) .setReadPendingIntent(msgHeardPendingIntent) .setReplyAction(replyPendingIntent, remoteInput);
  15. Intent msgHeardIntent = new Intent() .addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES) .setAction(com.myapp.messagingservice.ACTION_MESSAGE_HEARD) .putExtra("conversation_id", conversationId); PendingIntent

    msgHeardPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), conversationId, msgHeardIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  16. NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext()) .setSmallIcon(R.drawable.notification_icon) .setLargeIcon(icon_bitmap) .setContentText(messageString) .setWhen(currentTimestamp) .setContentTitle(participant_name)

    .setContentIntent(msgHeardPendingIntent); notificationBuilder.extend(new CarExtender() .setUnreadConversation(unreadConvBuilder.build()); NotificationManagerCompat msgNotificationManager = NotificationManagerCompat.from(context); msgNotificationManager.notify(notificationId, notificationBuilder.build());