Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play sound in Android notifications although phone silent mode is set

My app is showing notifications, and when a notification is shown, a sound is played. But when my phone is on "silent mode" the notification is not played. I want to "override" volume settings, and play a sound although silent mode is set. There is a way to do it?

like image 967
Sergio Viudes Avatar asked May 21 '13 07:05

Sergio Viudes


1 Answers

Hi you can use MediaPlayer as the notification sound, by starting a Service that play's the MediaPlayer when the notification is shown.

To make the sound stop, stop the service in the BroadCastReceiver of the notification's PendingIntent.

Also, don't forget to stop the sound when the notification cancels.

like image 134
Abdullah Avatar answered Oct 16 '22 17:10

Abdullah