notification's vibrate and sound defaults are working as INSISTENT
When an event happens my handler call开发者_运维知识库s my eventAlert() function that pops up a new notification. It doesnt matter if it is set with default flags or with custom sound, when notifiing comes the sound repeats itself just like with FLAG_INSISTENT. Even with FLAG_ONLY_ALERT_ONCE. If i specify a custom sound with Uri.parse it behaves the same way. All the same with vibration. However if a make a custom vibration, calling it with the Vibrator's vibreate(long[], int) function it only vibrates once as it should. What am i doing wrong, what is the most common mistake that leads here? How can i make it to vibrate and alert with sound only once? My eventAlert() is called once, im pretty sure. thx for your help!
Thanks for the answer, this piece of code is what most of us search for when creating notifications for first time:
notification.flags = Notification.FLAG_ONLY_ALERT_ONCE | Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE;
FLAG_AUTO_CANCEL clears the notification from the notification bar/list when clicking it.
精彩评论