安卓:通知操作驳回通知 [英] Android: Notification action to dismiss the notification

查看:89
本文介绍了安卓:通知操作驳回通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建具有操作按钮的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.

这篇关于安卓:通知操作驳回通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆