安卓:通知操作驳回通知

编程入门 行业动态 更新时间:2024-10-19 20:34:29
本文介绍了安卓:通知操作驳回通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图创建具有操作按钮的Andr​​oid通知。我已经设置一个启动该活动,但我想另一个则驳回通知,并没有考虑用户到另一个屏幕/活动(不考虑我的应用程序的任何部分)

I'm trying to create an android notification with action buttons. I have already set one up which starts an activity, but I would like another which dismisses the notification and doesn't take the user to another screen/Activity (not taken to any part of my app)

我不想用'。汽车取消(真)',因为我希望它能及时通知,除非这个动作按钮是pressed。

I don't want to use '.auto cancel(true) ' because I want the notification to be kept unless this action button is pressed.

的主要用途是对正在进行的通知,因为它们不能以滑动除去。我们的想法是类似与'驳回'行动了android日历。

The primary use would be for ongoing notifications as they cannot be removed with a swipe. The idea is similar to the android calender with the 'dismiss' action.

推荐答案

在创建通知,发送通知一个BroadcastReceiver。广播接收器时,通知操作是pressed他们启动的,所以取消()在广播接收机取消通知。

When the notification is created, send the notification to a broadcastreceiver. The broadcast receiver is them started when the notification action is pressed, so the cancel() in the broadcast receiver cancels the notification.

更多推荐

安卓:通知操作驳回通知

本文发布于:2023-11-27 08:04:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637203.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通知   操作

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!