public bool ActionRepresentDirectReply() { //Direct reply action is a new feature in Nougat, so when called on Marshmallow and backwards, so in those cases an Action will never represent a Direct Reply. if (Build.VERSION.SdkInt < BuildVersionCodes.N) { return(false); } remoteInputs = action.GetRemoteInputs(); if (remoteInputs == null || remoteInputs?.Length == 0) { return(false); } //In order to consider an action representing a Direct Reply we check for the ResultKey of that remote input. foreach (var remoteInput in remoteInputs) { if (remoteInput.ResultKey != null) { remoteInputDirectReply = remoteInput; return(true); } } return(false); }
public void RemoteInputProcessInput() { RemoteInput input = RemoteInputReceiver.Create(); Assert.Throws <ArgumentException>(() => input.ProcessInput(new byte[0])); input.Dispose(); }
public override void OnReceive(Context context, Intent intent) { IDictionary <string, object> parameters = new Dictionary <string, object>(); var extras = intent.Extras; if (extras != null && !extras.IsEmpty) { foreach (var key in extras.KeySet()) { parameters.Add(key, $"{extras.Get(key)}"); System.Diagnostics.Debug.WriteLine(key, $"{extras.Get(key)}"); } } var reply = RemoteInput.GetResultsFromIntent(intent)?.GetString("Result"); PushNotificationManager.RegisterAction(parameters, reply); NotificationManager manager = context.GetSystemService(Context.NotificationService) as NotificationManager; var notificationId = extras.GetInt(DefaultPushNotificationHandler.ActionNotificationIdKey, -1); if (notificationId != -1) { var notificationTag = extras.GetString(DefaultPushNotificationHandler.ActionNotificationTagKey, string.Empty); if (notificationTag == null) { manager.Cancel(notificationId); } else { manager.Cancel(notificationTag, notificationId); } } }
public void RemoteInputReceiverAll() { Assert.AreEqual(RemoteInputReceiver.All().Count, 0); RemoteInput input = RemoteInputReceiver.Create(); Assert.AreEqual(RemoteInputReceiver.All().Count, 1); input.Dispose(); Assert.AreEqual(RemoteInputReceiver.All().Count, 0); }
public void RemoteInputProperties() { RemoteInput input = RemoteInputReceiver.Create(); Assert.NotNull(input.RemoteMouse); Assert.NotNull(input.RemoteGamepad); Assert.NotNull(input.RemoteKeyboard); Assert.NotNull(input.RemoteTouchscreen); input.Dispose(); }
private string GetMessageText(Intent intent) { Bundle remoteInput = RemoteInput.GetResultsFromIntent(intent); if (remoteInput != null) { return(remoteInput.GetCharSequence(EXTRA_VOICE_REPLY)); } return(null); }
//Since API 24 Nougat. public bool SendInlineResponse(string responseText) { try { Bundle bundle = new Bundle(); Intent intent = new Intent(); bundle.PutCharSequence(remoteInputDirectReply.ResultKey, responseText); RemoteInput.AddResultsToIntent(remoteInputs, intent, bundle); action.ActionIntent.Send(Application.Context, Result.Ok, intent); return(true); } catch { return(false); } }
public PushNotificationResponse?FromIntent(Intent intent) { if (!intent.HasExtra(INTENT_KEY)) { return(null); } var notificationString = intent.GetStringExtra(INTENT_KEY); var notification = this.Services.Serializer.Deserialize <Shiny.Notifications.Notification>(notificationString); var action = intent.GetStringExtra(ShinyPushNotificationBroadcastReceiver.EntryIntentAction); var text = RemoteInput.GetResultsFromIntent(intent)?.GetString("Result"); var response = new PushNotificationResponse(notification, action, text); return(response); }
public async Task TryProcessIntent(Intent?intent) { if (intent == null || !this.delegates.Any()) { return; } if (intent.HasExtra(IntentNotificationKey)) { var notificationString = intent.GetStringExtra(IntentNotificationKey); var notification = this.serializer.Deserialize <Notification>(notificationString); var action = intent.GetStringExtra(IntentActionKey); var text = RemoteInput.GetResultsFromIntent(intent)?.GetString("Result"); var response = new NotificationResponse(notification, action, text); // the notification lives within the intent since it has already been removed from the repo await this.delegates.RunDelegates(x => x.OnEntry(response)); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.Settings); using (toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar)) { SetSupportActionBar(toolbar); SupportActionBar.SetDefaultDisplayHomeAsUpEnabled(true); } if (Build.VERSION.SdkInt > BuildVersionCodes.Kitkat) { Bundle remoteInput = RemoteInput.GetResultsFromIntent(Intent); if (remoteInput != null) { string response = remoteInput.GetCharSequence("test1"); Toast.MakeText(this, "The response is: " + response, ToastLength.Long).Show(); } } }
public void RemoteInputReceiverCreate() { RemoteInput input = RemoteInputReceiver.Create(); Assert.NotNull(input); }
/// <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) { Bundle remoteInput = RemoteInput.GetResultsFromIntent(intent); return(remoteInput != null?remoteInput.GetCharSequence(MessagingService.EXTRA_VOICE_REPLY) : null); }