public void ClickNotification() { try { CatcherHelper.statusBarNotifications[position].Notification.ContentIntent.Send(); //Android Docs: For NotificationListeners: When implementing a custom click for notification //Cancel the notification after it was clicked when this notification is autocancellable. if (IsRemovable()) { using (NotificationSlave notificationSlave = NotificationSlave.NotificationSlaveInstance()) { if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop) { int notiId = CatcherHelper.statusBarNotifications[position].Id; string notiTag = CatcherHelper.statusBarNotifications[position].Tag; string notiPack = CatcherHelper.statusBarNotifications[position].PackageName; notificationSlave.CancelNotification(notiPack, notiTag, notiId); } else { notificationSlave.CancelNotification(CatcherHelper.statusBarNotifications[position].Key); } } } } catch { Console.WriteLine("Click Notification failed, fail in pending intent"); } }
private void NotificationAdapterViewHolder_ItemLongClicked(object sender, Notificaciones.NotificationEventArgs.NotificationItemClickedEventArgs e) { position = e.Position; using (OpenNotification openNotification = new OpenNotification(e.Position)) { if (openNotification.IsRemovable()) { using (NotificationSlave notificationSlave = NotificationSlave.NotificationSlaveInstance()) { if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop) { int notiId = CatcherHelper.statusBarNotifications[position].Id; string notiTag = CatcherHelper.statusBarNotifications[position].Tag; string notiPack = CatcherHelper.statusBarNotifications[position].PackageName; notificationSlave.CancelNotification(notiPack, notiTag, notiId); } else { notificationSlave.CancelNotification(CatcherHelper.statusBarNotifications[position].Key); } } floatingNotificationView.Visibility = ViewStates.Gone; } } }
private void ItemLongClicked(object sender, NotificationItemClickedEventArgs e) { position = e.Position; notification.Visibility = ViewStates.Visible; using (OpenNotification openNotification = new OpenNotification(e.Position)) { //If the notification is removable... if (openNotification.IsRemovable()) { //Then remove the notification using (NotificationSlave slave = NotificationSlave.NotificationSlaveInstance()) { if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop) { int notiId = CatcherHelper.statusBarNotifications[position].Id; string notiTag = CatcherHelper.statusBarNotifications[position].Tag; string notiPack = CatcherHelper.statusBarNotifications[position].PackageName; slave.CancelNotification(notiPack, notiTag, notiId); } else { slave.CancelNotification(CatcherHelper.statusBarNotifications[position].Key); } } notification.Visibility = ViewStates.Invisible; titulo.Text = null; texto.Text = null; notificationActions.RemoveAllViews(); } } }
public void Cancel() { if (IsRemovable()) { using (NotificationSlave slave = NotificationSlave.NotificationSlaveInstance()) { if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop) { slave.CancelNotification(GetPackageName(), GetTag(), GetId()); } else { slave.CancelNotification(GetKey()); } } } }
public void Cancel() { if (IsRemovable()) { using (NotificationSlave slave = NotificationSlave.NotificationSlaveInstance()) { //If this notification has a mediacontroller callback registered we unregister it, to avoid leaks. if (mediaController != null) { mediaController.UnregisterCallback(MusicController.GetInstance()); } if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop) { slave.CancelNotification(GetPackageName(), GetTag(), GetId()); } else { slave.CancelNotification(GetKey()); } } } }
public void OnItemLongClick(int position) { if (Catcher.listaNotificaciones[position].IsClearable == true) { int notiId = Catcher.listaNotificaciones[position].Id; string notiTag = Catcher.listaNotificaciones[position].Tag; string notiPack = Catcher.listaNotificaciones[position].PackageName; NotificationSlave slave = new NotificationSlave(); slave.CancelNotification(notiPack, notiTag, notiId); v.Visibility = ViewStates.Invisible; } else { Toast.MakeText(Application.Context, "No", ToastLength.Short).Show(); } }