Johnathan Au
Johnathan Au

Reputation: 5362

How can I set off an alarm i.e. play an alarm tone in Android?

I want to build an alarm application but I don't know how to set off an alarm ringtone when the alarm has gone off. How do I do this?

Upvotes: 0

Views: 184

Answers (1)

Yalla T.
Yalla T.

Reputation: 3727

Since youre Question is pretty broad and generic, I cant provide exact Code but i can point you to the things you need to do.

You need to create a PendingIntent which starts a Service. In the Service you need to play the Sound with a MediaPlayer. The Media Playback Link also has a specific section on playing Sound in a Service. To schedule the PendingIntent to be fired at a certain time and start the service then, use AlarmManager.

Upvotes: 1

Related Questions