我试图创建具有操作按钮的Android通知。我已经设置一个启动该活动,但我想另一个则驳回通知,并没有考虑用户到另一个屏幕/活动(不考虑我的应用程序的任何部分)
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.
更多推荐
安卓:通知操作驳回通知
发布评论