How to play a short beep to Android Phone’s loudspeaker programmatically

I recommend you use the ToneGenerator class. It requires no audio files, no media player, and you can customize the beep’s volume, duration (in milliseconds) and Tone type. I like this one:

ToneGenerator toneGen1 = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);             
toneGen1.startTone(ToneGenerator.TONE_CDMA_PIP,150);  

You can see into the ToneGenerator object (CMD + click over ToneGenerator. , in Mac), and choose another beep type besides TONE_CDMA_PIP, 150 is the duration in milliseconds, and 100 the volume.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)