我想说一些文本。由于一些奇怪的原因,屏蔽STREAM_RING也将文本转换为语音。我搜索了互联网,但我想没有人有过这个问题,所以我无法找到答案。这里是我的代码:setStreamMute(STREAM_RING)静音文本到语音android
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);
}
}
}
嗨,你可以使用这个想法,就接到电话,而不是静音环流可以作为沉默的临时设置的铃声,完成你的任务,那么你可以恢复它,如果你真的需要。要设置铃声使用System.Settings类 –