【问题标题】:how to clear the item on notification bar by using phonegap localnotification plugin如何使用phonegap localnotification插件清除通知栏上的项目
【发布时间】:2012-11-15 04:46:20
【问题描述】:

作为标题,我使用的是 android localnotification phonegap 插件。现在我可以在那个栏上强制通知,如果我触摸那个,应用程序将重新打开,但那个通知仍然在通知栏上。

所以这里的问题是如何在应用重新打开后清除通知栏上的通知?

谢谢。

【问题讨论】:

  • 仍在等待答案...

标签: javascript android cordova localnotification


【解决方案1】:

AlarmReceiver.java 中查看AlarmReceiver::onReceive(Context context, Intent intent)。您必须为Notification 设置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);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-24
    相关资源
    最近更新 更多