1

I am developing a media player application in android. For that i need to know alarm is ringing or not. If alarm is ringing my application should pause music,As soon as alarm stopped ringing my application should play music again. Please let me know any one have idea how to determine alarm is ringing or not from android application.

Here i added some investigations on this. But those are not suggest ways to use.

How to detect alarm ringing or other apps using speaker?

Listing of manufacturer's clock / alarm package and class name, Please add

Community
  • 1
  • 1
Raghu Mudem
  • 6,793
  • 13
  • 48
  • 69
  • The alarm ringing is but one example -- there are many other bits of audio playback, such as incoming call ringtones, that you should care about as well. Research "audio ducking" to learn the proper stuff to register to find out when other apps wish to play audio while you are playing audio. – CommonsWare May 27 '15 at 11:06
  • 1
    @CommonsWare Thank you for your response. I used "requestAudioFocus" for handling other bits. In my case i need to give high priority for Alarm ring. So I want to pause my media player when Alarm ringing and i need to play my media player once alarm done. Any Suggestions to detect only Alarm. Or any best practice tutorial for handling alarm. And i have gone through one of your answer from the link "http://stackoverflow.com/questions/2713484/how-to-handle-alarm-notification-in-android" and i understood there is no android api to detect alarm is ringing or not. Please correct me. – Raghu Mudem May 27 '15 at 11:16
  • "i understood there is no android api to detect alarm is ringing or not" -- mainly because "alarm" is a marketing term more than a technical one. After all, there are countless apps with "alarm" functionality on the Play Store. Ideally, they would all use `STREAM_ALARM` for things like volume, and perhaps there is some way through the audio focus APIs to determine the stream type of the new audio source. However, there is no requirement that an "alarm" app use `STREAM_ALARM` or otherwise declare itself to the world as an "alarm" app from a programming standpoint. – CommonsWare May 27 '15 at 11:34

0 Answers0