0
我試圖做一個應用程序,當來電來標識數字和通過使用android文本語音它會說聯繫人的名字。我已經完成了幾乎我的問題是,當來電而不是默認鈴聲,它應該說TTS.how覆蓋鈴聲與TTS 在這裏我給我所嘗試的。任何人都可以幫助我獲得更好的解決方案。我已經嘗試了第一個答案,現在戒指音量變得很弱。但聽起來不會來。在Android中改變鈴聲與tts
public class myPhoneStateChangeListener extends PhoneStateListener
{
int ph_state = 0;
speechcontact clsspcntct = new speechcontact();
@Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
if (state == TelephonyManager.CALL_STATE_RINGING)
{
String phoneNumber = incomingNumber;
String ContactName = objUtility.getContactName2(context,phoneNumber);
if (RBSpkMde.isChecked())
{
speakWords(ContactName);
}
}
}
public void speakWords(String speech)
{
myTTS.speak("you have call from"+speech, TextToSpeech.QUEUE_FLUSH, null);
}
}
我應該在哪裏申請呢? – 2013-03-27 09:15:34
裏面if(state == TelephonyManager.CALL_STATE_RINGING)。因此,只需在if語句後面加上前兩行即可。如果您希望電話在演講結束後恢復正常響鈴,則在完成之後完成後面的兩行。如果不是,則將其放在CALL_STATE_IDLE – 2013-03-27 09:19:47
mRingVolume的數據類型是什麼? – 2013-03-27 09:32:31