Top Banner
Android Wear Voice Input +Anuchit Chalothorn [email protected]
12

02 Android Wear Voice Input

Jul 14, 2015

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 02 Android Wear Voice Input

Android WearVoice Input

+Anuchit [email protected]

Page 2: 02 Android Wear Voice Input

Voice Input

Android Wear device using touch screen and voice to input command. You can use intent remote input to dictation voice command.

Page 3: 02 Android Wear Voice Input

Pending Intent

Intent intent = new Intent(this,NotificationActivity.class);

PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);

String replayLabel = getResources().getString(R.string.label_reply);

String[] replyChoices = getResources().getStringArray(R.array.reply_choices);

Page 4: 02 Android Wear Voice Input

Voice Input with choices

RemoteInput remoteInput = new RemoteInput.Builder(NotificationUtils.EXTRA_VOICE_REPLY)

.setLabel(replayLabel)

.setChoices(replyChoices)

.build();

Page 5: 02 Android Wear Voice Input

Set Action Menu

NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.ic_reply,"Answer",pendingIntent)

.addRemoteInput(remoteInput)

.build();

Page 6: 02 Android Wear Voice Input

Set Notification

Notification notification = new NotificationCompat.Builder(this)

.setContentTitle("Notification Title")

.setContentText("Notification Text")

.setSmallIcon(R.drawable.ic_launcher)

.setContentIntent(pendingIntent)

.extend(new NotificationCompat.WearableExtender().addAction(action))

.build();

Page 7: 02 Android Wear Voice Input

Show Notification

NotificationManagerCompat manager = NotificationManagerCompat.from(this);

manager.notify(1,notification);

Page 8: 02 Android Wear Voice Input
Page 9: 02 Android Wear Voice Input

Remote Input Result

private CharSequence getMessageText(Intent intent) {

Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);

if (remoteInput!=null) {

return remoteInput.getCharSequence(NotificationUtils.EXTRA_VOICE_REPLY);

}

return null;

}

Page 10: 02 Android Wear Voice Input

Remote Input Result

private CharSequence getMessageText(Intent intent) {

Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);

if (remoteInput!=null) {

return remoteInput.getCharSequence(NotificationUtils.EXTRA_VOICE_REPLY);

}

return null;

}

Page 11: 02 Android Wear Voice Input
Page 12: 02 Android Wear Voice Input

Thank You

Licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.