Я внедряю систему уведомлений с использованием платформы Xamarin, которая распространяется на носимые устройства для отправки уведомления. Я также хочу получить вход пользователя из уведомления об износе, и я запрограммировал его так, чтобы пользователь мог выбрать текст или использовать голос. я последовал следующий учебникКак получить входные данные от носимых устройств
http://developer.android.com/training/wearables/notifications/voice-input.html
мой код:
void SendWearNotification (string message, string from)
{
var valuesForActivity = new Bundle();
valuesForActivity.PutString ("message", message);
String groupkey = "group_key_emails";
var intent = new Intent (this, typeof(MyMainActivity));
intent.PutExtras (valuesForActivity);
intent.AddFlags (ActivityFlags.ClearTop);
var pendingIntent = PendingIntent.GetActivity (this, 0, intent, PendingIntentFlags.OneShot);
var builder = new NotificationCompat.Builder (this)
.SetAutoCancel (true)
.SetContentIntent (pendingIntent)
.SetContentTitle (from)
.SetSmallIcon (Resource.Drawable.Iconlogo)
.SetContentText (message) //message is the one recieved from the notification
.SetTicker(from)
.SetGroup (groupkey) //creates groups
.SetPriority((int)NotificationPriority.High);
//
//for viewing the message in second page
var pagestyle= new NotificationCompat.BigTextStyle();
pagestyle.SetBigContentTitle (from)
.BigText (messagefromapp); //message from app is the one rerieved from the wcf app
//second page
var secondpagenotification = new NotificationCompat.Builder (this)
.SetStyle (pagestyle)
.Build();
//intent for voice input or text selection
var wear_intent = new Intent (Intent.ActionView);
var wear_pending_intent = PendingIntent.GetActivity (this,0,wear_intent,0);
// Create the reply action and add the remote input
setRemoteInput();
var action = new NotificationCompat.Action.Builder (Resource.Drawable.ic_mes,
GetString (Resource.String.messages), wear_pending_intent)
.AddRemoteInput (remoteinput)
.Build();
//add it to the notification builder
Notification notification = builder.Extend (new NotificationCompat.WearableExtender()
.AddPage (secondpagenotification).AddAction(action)).Build();
//create different notitfication id so that we can as list
if(notification_id<9){
notification_id += 1;
}else{
notification_id=0;
}
var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
notificationManager.Notify (notification_id+2, notification);
}
этот метод implmented внутри класса GCMListnerService.
Согласно обучающей ссылке выше, я могу извлечь пользователя ввода данных, выбранного или говорил uing следующий код:
private void getResponse(Intent intent){
Bundle remoteInput = RemoteInput.GetResultsFromIntent(intent);
if (remoteInput != null) {
Toast.MakeText(this, remoteInput.GetCharSequence(EXTRA_VOICE_REPLY), ToastLength.Short);
}
//return null;
}
Мой вопрос, когда я называю этот метод, как я знаю, пользователь выбрал текст, отправленный с переносимого устройства. если есть какое-либо событие, которое я могу использовать.
Во-первых, ссылка, которую вы пытались включить в свой пост, не отображается, поэтому, пожалуйста, отредактируйте и исправьте это. Во-вторых, пожалуйста, сформулируйте свой вопрос более четко, я не уверен, что есть достаточно информации, чтобы увидеть, что вы хотите делать, что вы сделали и в чем проблема. –
спасибо за ваш комментарий, я надеюсь, что теперь ясно, что я имел в виду? – user3406302