Ongoing notifications
I am trying to create a notification that will appear in the "ongoing" area of the notification bar (like WeatherBug).
Here is the code that I am usi开发者_如何学编程ng:
PendingIntent intent = PendingIntent.getActivity(lastContext, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT | Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR)
From what I understand, FLAG_NO_CLEAR, should also prevent the notification from being cleared by pressing the Clear button, this is also not working
Any tips SO?
This is because you are using the flags in the wrong place.
You should be doing:
notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;
After you create your Notification
object and before you call NotificationManager#notify
精彩评论