Reputation: 31
I have a simple app that looks for a pattern of text in the incoming text message, and then alerts. Based on the text, the alert may have to last for a minute (like a pager). Notification alert sound is being set off, but the problem is.. the default SMS notification alert takes over (while my alert is supposed to last for a minute or more).
How do I handle this?
Upvotes: 1
Views: 235
Reputation: 31
AudioManager.requestAudioFocus places a request for the audio device, which if is granted, must be handled by the AudioManager.onAudioFocusChangeListener. Do remember to call abandonAudioFocus once you are done with your stuff!
Upvotes: 1
Reputation: 39797
One option may be to simply provide a brief delay before you create the notification (giving the system time to do its thing first), however since you want the sound to last up to a minute or more, I would suggest not playing the sound as part of your notification. Instead, play it as an mp3 (which will be briefly interrupted by the system notification, but then returned to playing) and cancel its play early if the user does the right thing (touches your notification, opens your activity, etc.)
Upvotes: 1