I am making an Speaking caller name application which pause the ringtone before speaking the caller name using TextToSpeech
. I am detecting the current Volume
using
int musicVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
Mostly this returns 0
but sometimes 15
the correct value. The phone is in normal mode and the volume of phone is full. I need this value to correctly speak the caller name but this unpredictable behaviour is making me crazy.
What wrong am i doing? Isn't this the correct way to detect ringtone volume?
It places the example below that it functions, volume is of 0 to the 15.
public void pegarVolume(){
AudioManager AudioManager = (AudioManager) getSystemService (Context.AUDIO_SERVICE);
int musicVolume = AudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
}