![](/img/trans.png)
[英]how to show the number of notification in the status bar using android phonegap
[英]how to clear the item on notification bar by using phonegap localnotification plugin
作為標題,我正在使用android localnotification phonegap插件。 現在,我可以在該欄上強制發送通知,如果我觸摸該欄,則該應用將重新打開,但該通知仍在通知欄上。
因此,這里的問題是,一旦重新打開應用程序,如何清除通知欄上的通知?
謝謝。
在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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.