[英]how to clear the item on notification bar by using phonegap localnotification plugin
As the title, I'm using android localnotification phonegap plugin. 作为标题,我正在使用android localnotification phonegap插件。 Now I can force a notification on that bar, and if I touch on that one, the app will be re-open, but that notification is still on the notification bar.
现在,我可以在该栏上强制发送通知,如果我触摸该栏,则该应用将重新打开,但该通知仍在通知栏上。
So the question here is how to clear that notification on the notification bar once the app was re-opened? 因此,这里的问题是,一旦重新打开应用程序,如何清除通知栏上的通知?
Thanks. 谢谢。
In AlarmReceiver.java
look at AlarmReceiver::onReceive(Context context, Intent intent)
. 在
AlarmReceiver.java
查看AlarmReceiver::onReceive(Context context, Intent intent)
。 You have to set AutoCancel
for the Notification
. 您必须为
Notification
设置AutoCancel
。
Depending on the API version you are using this may look different. 根据您使用的API版本,此外观可能有所不同。 For the version 17 it could look like this:
对于版本17,它可能如下所示:
final Notification notification = new NotificationCompat.Builder(context)
.setTicker(tickerText)
.setSmallIcon( context.getResources().getIdentifier("myicon" ,
"drawable", context.getPackageName()) )
.setWhen(System.currentTimeMillis())
.setContentTitle(notificationTitle)
.setContentText(notificationSubText)
.setContentIntent(contentIntent)
// .setVibrate(new long[] { 0, 100, 200, 300 })
.setAutoCancel(true) // <------- here you remove the message
.build();
notificationMgr.notify(notificationId, notification);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.