簡體   English   中英

如何通過使用phonegap localnotification插件清除通知欄上的項目

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM