How to make ToneGenerator play longer than 3 seconds

2.3k views Asked by At

I have this code

 ToneGenerator tg=new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
 tg.startTone(ToneGenerator.TONE_CDMA_ONE_MIN_BEEP, 5000);

works fine but the playing of the beep is very shot (around 200ms)

No matter if I set 5000ms or more for the duration , still nothing changes :(.

Is it possible to have control on the duration of how long the beep is played ?

//this is the definition of the function defined in android
public boolean startTone (int toneType, int durationMs)
1

There are 1 answers

0
Tiralka On

I think that the problem is the tone you used: TONE_CDMA_ONE_MIN_BEEP is a beep of duration 400 ms (link)

You should use a beep (you can find some on the page I linked) that is continuous or lasts at least 5000 ms.