I would like my app beep with a specific frequency and duration. In the windows equivalent of this app (written in c#) I used a c++ dll with the function
beep(frequency, duration);
Is this the same in android? Or at least how can I put my c++ dll in the project?
I would prefer not to use pre-built mp3's or system sound because I would like to give the user the choice of the frequency and duration.
It may be some kind of notification from one of your recent downloaded app or any app which is set to remind you something. try to uninstall your recent downloaded app and when you here the beeping immediately check for the running app or if any notification is there.
I tried amine.b's answer. In short, to play a loud Beep sound:
ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100); toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200);
The easy way is to use instance of ToneGenerator
class:
// send the tone to the "alarm" stream (classic beeps go there) with 50% volume ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 50); if (val >= taux_max) { taux_text.setTextColor(warnning_col); toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200); // 200 is duration in ms }
Please refer to the documentation of ToneGenerator
and AudioManager
for exact meaning of parameters and possible configuration of the generator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With