public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            if (intent == null || intent.Action == null)
            {
                return(StartCommandResult.Sticky);
            }
            var action = intent.Action;

            if (action.Equals(ACTION_RESPONSE))
            {
                var remoteInputResults = RemoteInput.GetResultsFromIntent(intent);
                var replyMessage       = "";
                if (remoteInputResults != null)
                {
                    replyMessage = remoteInputResults.GetCharSequence(EXTRA_REPLY);
                }
                ProcessIncoming(replyMessage.ToString());
            }
            else if (action.Equals(MainActivity.ACTION_GET_CONVERSATION))
            {
                BroadcastMessage(mCompleteConversation.ToString());
            }
            return(StartCommandResult.Sticky);
        }
Пример #2
0
        /// <summary>
        /// Get the message text from the intent.
        /// Note that you should call <see cref="Android.Support.V4.App.RemoteInput.GetResultsFromIntent(intent)"/>
        /// to process the RemoteInput.
        /// </summary>
        /// <returns>The message text.</returns>
        /// <param name="intent">Intent.</param>
        static string GetMessageText(Intent intent)
        {
            var remoteInput = RemoteInput.GetResultsFromIntent(intent);

            return(remoteInput != null?remoteInput.GetCharSequence(MainActivity.KEY_TEXT_REPLY) : string.Empty);
        }