Reputation: 725
I am working on an Android project and I want to raise some kind of alert or sound. I have implemented a countdown timer and once the countdown timer stops, an alarm or alert sound should be raised.
Any idea how can I implement this in Android. Is there any particular class I can use for it?
Upvotes: 0
Views: 5652
Reputation: 1946
create raw folder in your resource and copy your song then use this code
notification.sound = Uri.parse("android.resource://com.mosi.persianbirthday/" + R.raw.tavalod);
Upvotes: 0
Reputation: 11844
You could use the notification class.. look here http://developer.android.com/guide/topics/ui/notifiers/notifications.html
if you don't need notification and just wants to play lets say a mp3 file you could use the MediaPlayer class http://developer.android.com/reference/android/media/MediaPlayer.html
or if you prefer to play a raw audio file you can use the AudioManager together with the SoundPool class from android.media package. do look for examples on the internet heres a good example http://android-er.blogspot.com/2010/11/play-foreground-and-background-music.html
good luck with your codes!
Upvotes: 2