Currently I need to capture the moment when the ringing of an outgoing call starts over the speaker of an Android phone. According to Abeer Ahmad at " How to identify the ringing state of outgoing call in android ", a solution would detect the frequency change of the emitted sound (from 0 to the value corresponding to the ringer) using the class Visualizer . However, no frequency value other than 0 (silence) is detected while making a call. This does not correspond to what happens when the mobile emits another sound, such as the reproduction of an audio track, where the frequency values are detected. Could someone help me, or give me an alternative solution?
Here is my code:
mVisualizer = new Visualizer(0);
mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
Visualizer.OnDataCaptureListener listener = new Visualizer.OnDataCaptureListener(){
@Override
public void onWaveFormDataCapture(Visualizer visualizer, byte[] bytes, int samplingRate) { }
@Override
public void onFftDataCapture(Visualizer visualizer, byte[] bytes, int samplingRate) {
for (int i=0;i<bytes.length;i++) {
if (bytes[i] != 0) {
Log.i("INFO","FRECUENCIA:"+bytes[i]);
break;
}
}
}
};
mVisualizer.setDataCaptureListener(listener, Visualizer.getMaxCaptureRate() / 2, true, true);
The android version where I'm testing it is Android Jellybean (API 17).