I have a service that is set up to either run in the background (using startForeground(int, Notification) ), or as part of the application that created it.
I have two notifications, and being for different purposes, I want them to do different things.
The first one is just to alert the user that the service is still running in the background, so I've set it's flags as follows:
The second notification is an error message, which could occur while the service is running in the background, so for now, I've set it's flags as follows:
Now, as I understand from the API documentation, this second notification should play the default notification sound, vibrate in some default way, and flash the LED in some default pattern.
Instead, all I get is the sound. However, if I add DEFAULT_ALL to the first notification, I get both the sound and vibration as expected, and if I add the FLAG_SHOW_LIGHTS flag to the first one, it will flash the LED as well.
I have also tried defining my own vibration pattern for the second one, as follows:
and only turning on DEFAULT_SOUND and DEFAULT_LIGHTS. Still no vibration.
The only other difference between these two notifications (other than the text and the icon used), is that the first one is displayed using startForeground(int, Notification), and the second is displayed using the notification manager's notify(int, Notification) method.
What am I doing wrong with the second notification?
I have two notifications, and being for different purposes, I want them to do different things.
The first one is just to alert the user that the service is still running in the background, so I've set it's flags as follows:
Code:
notification.flags = Notification.FLAG_FOREGROUND_SERVICE | Notification.FLAG_NO_CLEAR
| Notification.FLAG_ONGOING_EVENT;
Code:
notification.defaults = Notification.DEFAULT_ALL
notification.flags = Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS;
Instead, all I get is the sound. However, if I add DEFAULT_ALL to the first notification, I get both the sound and vibration as expected, and if I add the FLAG_SHOW_LIGHTS flag to the first one, it will flash the LED as well.
I have also tried defining my own vibration pattern for the second one, as follows:
Code:
long[] vibrate = {0, 100, 200, 100};
notification.vibrate = vibrate;
The only other difference between these two notifications (other than the text and the icon used), is that the first one is displayed using startForeground(int, Notification), and the second is displayed using the notification manager's notify(int, Notification) method.
What am I doing wrong with the second notification?