我正在尝试说一些文字。由于某些奇怪的原因,静音 STREAM_RING 也将文本静音。我已经搜索过互联网,但我想以前没有人遇到过这个问题,所以我找不到答案。这是我的代码:
int volume=0;
if(state == TelephonyManager.CALL_STATE_RINGING)
{
Toast.makeText(getApplicationContext(), "Inside", Toast.LENGTH_SHORT).show();
if(incomingNumber != null)
{
volume= audioManager.getStreamVolume(AudioManager.STREAM_RING);
audioManager.setStreamMute(AudioManager.STREAM_RING, true);
audioManager.setStreamVolume(AudioManager.STREAM_RING, 0, AudioManager.FLAG_ALLOW_RINGER_MODES);
tts.speak(incomingNumber, TextToSpeech.QUEUE_FLUSH, null);
Toast.makeText(getApplicationContext(), "speak number", Toast.LENGTH_SHORT).show();
}
if(state == TelephonyManager.CALL_STATE_IDLE)
{
audioManager.setStreamVolume(AudioManager.STREAM_RING, volume, AudioManager.FLAG_ALLOW_RINGER_MODES);
audioManager.setStreamMute(AudioManager.STREAM_RING, false);
}
}
}