Search code examples
androidnotificationsnotificationmanager

How to stop and play notifications continuously?


I want to achieve this :

  • When alarm starts ringing the notification sound should play continuously until the user drag notification bar.
  • When I drag down the notification bar the sound should stop playing.

Solution

  • In notifications there are few flags that are used to stop notification automatically u have to use them those are.

    1. Notification.DEFAULT_SOUND:used to play sound.

    2.Notification.FLAG_INSISTENT:this flag is makes your sound to ring continuously until you have done few operations on notification ie, either you drag the bar or you click the bar.

    3.Notification.FLAG_AUTO_CANCEL:this flag is used to automatically cancel the notification after you have seen it