Ok,
Possibly another bizare undocumented quirk of android, but I'm finding something quite odd when adding flags to my notification...
If I do this:
Notification notification = new Notification(R.drawable.status_icon, "[Ticker Text]",System.currentTimeMillis());
PendingIntent intent = PendingIntent.getActivity(this, 0, new Intent(this, CarparkScreen.class), 0);
notification.setLatestEventInfo(AlertService.this,"[Title]", "[Detail]", intent);
mNM.notify(NOTIFICATION_BREACH, notification);
Then the notification appears as a one off, clicking cancels is and you can clear it in the normal way.
If however I add these flags
Notification notification = new Notification(R.drawable.status_icon, "[Ticker Text]",System.currentTimeMillis());
PendingIntent intent = PendingIntent.getActivity(this, 0, new Intent(this, CarparkScreen.class), 0);
notification.setLatestEventInfo(AlertService.this,"[Title]", "[Detail]", intent);
notification.flags = Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS;
mNM.notify(NOTIFICATION_BREACH, notification);
It creates an ongoing notification, despite there being no ongoing flag!!
I think its actually the DEFAULT_VIRBATE flag which is causing this, which at first I though was because I didn't have vibrate permissions, but I've added that now but it still causes the notification to be ongoing.
Urgh!!!!
Can anyone else re-create this? Seems such an obvious use case to be a bug or quirk.
I am actually using an ongoing notification at the same time as trying to create a non-ongoing notification above, but this really shouldn't cause this as I'm using new instances of everything apart from the NotificationManager. The ID in the above code is also different to the ongoing notification.
Any ideas muchly appreciated! :)
Andy.
It creates an ongoing notification, despite there being no ongoing flag!!
The flags
field gets FLAG_
constants. The defaults
field get DEFAULT_
constants. You are putting DEFAULT_
constants in the flags
field. Try changing your code to use the defaults
field.