如何解雇Android的通知操作已被点击后, [英] How to dismiss Android notification after action has been clicked
问题描述
由于API级别16(果冻豆),还有就是动作加入到通知的可能性,以
Since API level 16 (Jelly Bean), there is the possibility to add actions to a notification with
builder.addAction(iconId, title, intent);
但是,当我添加一个行动的通知和动作是pressed,该通知不会被解雇。 当通知本身正在被点击时,它可以与被驳回
But when I add an action to a notification and the action is pressed, the notification is not going to be dismissed. When the notification itself is being clicked, it can be dismissed with
notification.flags = Notification.FLAG_AUTO_CANCEL;
或
builder.setAutoCancel(true);
但很明显,这有什么可与相关的通知的行动。
But obviously, this has nothing to with the actions associated to the notification.
任何提示?或者是API的这一部分不还?我没有发现任何东西。
Any hints? Or is this not part of the API yet? I did not find anything.
推荐答案
当你打电话通知的通知经理,你给它一个id - 这是唯一的ID,您可以使用更高版本来访问它(这是从通知管理
When you called notify on the notification manager you gave it an id - that is the unique id you can use to access it later (this is from the notification manager:
notify(int id, Notification notification)
要取消的话,会叫:
cancel(int id)
用相同的ID。所以,基本上,你需要不断的ID曲目或可能将ID为一个包添加到PendingIntent?
with the same id. So, basically, you need to keep track of the id or possibly put the id into a Bundle you add to the Intent inside the PendingIntent?
这篇关于如何解雇Android的通知操作已被点击后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!