Javascript 如何使用phonegap localnotification插件清除通知栏上的项目

Javascript 如何使用phonegap localnotification插件清除通知栏上的项目,javascript,android,cordova,localnotification,Javascript,Android,Cordova,Localnotification,作为标题,我使用的是android localnotification phonegap插件。现在,我可以在该条上强制发送通知,如果我点击该条,应用程序将重新打开,但该通知仍在通知条上 所以这里的问题是,一旦应用程序重新打开,如何清除通知栏上的通知 谢谢。在AlarmReceiver.java中查看AlarmReceiver::onReceive(上下文,意图)。您必须为通知设置AutoCancel 根据您使用的API版本,这可能会有所不同。对于版本17,它可能如下所示: final Notif

作为标题,我使用的是android localnotification phonegap插件。现在,我可以在该条上强制发送通知,如果我点击该条,应用程序将重新打开,但该通知仍在通知条上

所以这里的问题是,一旦应用程序重新打开,如何清除通知栏上的通知


谢谢。

AlarmReceiver.java
中查看
AlarmReceiver::onReceive(上下文,意图)
。您必须为
通知设置
AutoCancel

根据您使用的API版本,这可能会有所不同。对于版本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);
final Notification Notification=new NotificationCompat.Builder(上下文)
.setTicker(tickerText)
.setSmallIcon(context.getResources().getIdentifier(“myicon”),
“可绘制”,context.getPackageName())
.setWhen(System.currentTimeMillis())
.setContentTitle(notificationTitle)
.setContentText(notificationSubText)
.setContentIntent(contentIntent)
//.setVibrate(新长[]{0,100,200,300})

.setAutoCancel(true)//仍在等待答案。。。