Android: Is it possible to detect Alarm is ringing from android application? - android

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

Related

Thoughts on best way to make a sound for alarm clock app, and to have it's volume attached to the alarm clock system volume and not media volume?

Hello, I am having trouble figuring out the best way to make an alarm clock noise for my alarm clock app. I want to start the noise when the broadcast receiver is activated. I am able to create a media player, but the noise is attached to the media volume. I am not sure how to tie the noise to the alarm volume like google clocks. See image please, or at least the notification volume. I don't want it to run off media volume in case someone has it low, and makes the alarm pointless.

What is the best way to play an alarm ringtone when broadcast receiver is called?

I am having trouble finding the best way to activate an alarm tone. My broadcast receiver is called, the media player starts, but then stops. after about a second when my alarm app is closed and not open in recent apps. It will play continuously if the alarm app is open. Does anyone know the best way to play a sound once an alarm broadcast receiver goes off?
I found out what it was. It was apparently because my media player was getting destroyed by the garbage collector. So this answer https://stackoverflow.com/a/7719296/14727778 pointed out to use the media player as class level variable instead of declaring it in a method, so it does not get swept away. Pretty obvious! howd I miss that.....

Set an alarm in android

I'm trying to set up an alarm once a day so my user knows that he needs to check the app (extracts data from bluetooth devices, etc)
So far, I have used AlarmManager.setExactAndAllowWhileIdle(...), and a broadcastreceiver that plays some sound in the onReceive method, but this won't work when app enters App Standby.
Anyone knows how to properly set an alarm that prompts no matter if the device is in Doze or the app is in App Standby?

How to detect the alarm event?

I´m developing a music application.
When an alarm starts, the streaming of music must stop. The problem is how to detect the alarm event. The alarm may sound at any time. It is set by the user with the android alarm system.

Using the built in alarm system, not just alarm manager

I writing something that schedules events at various time. Right now I just create a pendingintent and use the alarm manager to call a broadcast receiver at a specific time. This then calls a transparent activity with a dialog box and runs vibration/ a media player to mimic an alarm clock. One of the problems with this, is that then the alarm is privy to the media volume settings rather than the alarm volume settings.
Another problem is, I'd like users to be able to see the alarm amongst the system alarms. I would imagine this has something to do with it http://developer.android.com/reference/android/provider/AlarmClock.html
But it doesn't seem like you have control over things like ringtone, vibration pattern, volume etc. At the very least I'd like to play an alarm sound which volume is not affected by the media volume levels.
What is the best solution here for creating an alarm that really mimics the system and feels to be integrated with android very well? I'm stumped as every search I do just brings up info about alarmmanager
One of the problems with this, is that then the alarm is privy to the media volume settings rather than the alarm volume settings.
You can tell MediaPlayer what volume stream to use.
But it doesn't seem like you have control over things like ringtone, vibration pattern, volume etc.
Correct. The AlarmClock ContentProvider is providing data for the device's built-in AlarmClock application. It is not providing data for you.
At the very least I'd like to play an alarm sound which volume is not affected by the media volume levels.
You can tell MediaPlayer what volume stream to use.
What is the best solution here for creating an alarm that really mimics the system and feels to be integrated with android very well?
The user is perfectly capable of using the device's built-in AlarmClock application for this.

Categories

Resources