Android: Looking for an easy way to play notification sounds in a loop manually
I am fiddling around with a dialog that pops up and displays an alarm information. (I know, it has been documented that in Android it's "better" style to use notifica开发者_高级运维tions instead, but just like the alarm clock I want it to display a dialog on top of whatever you do to really get the users immediate attention - as the user expects this behavior I don't think it's bad style!)
Now - the only easy way I found is using the RingtoneManager.getRingtone()
function to get a Ringtone
object for the type "alarm".
Well, I can play that sound now using Ringtone.play()
- but it plays the sound only once and I cannot figure out how to let it play endlessly until the user reacts, e.g. by touching the dialog anywhere or dismissing it using Cancel button provided.
Does anyone know how this can be accomplished easily? Thanks!
Take a look at AlarmClock
from Android's git repository. It might be helpful to check out the source code on how to play sounds for an expected duration.
精彩评论