Tts.java
public void onInit(int arg0) {
Bundle dataBundle = Tts.this.getIntent().getExtras();
speech = dataBundle.getString("IMSENS");
tts.setLanguage(Locale.ENGLISH);
tts.speak(speech, TextToSpeech.QUEUE_FLUSH, null);
}
Im_SensShow.java
public class Im_SensShow extends ListActivity {
public void buttonGetClicked(View v){
Cursor cc = cursor;
Intent showSound = new Intent(Im_SensShow.this,Tts.class);
Bundle dataBundle = new Bundle();
dataBundle.putString("IMSENS",cc.getString(cc.getColumnIndexOrThrow(DBAdapter.KEY_IM_SENS)));
showSound.putExtras(dataBundle);
startActivityForResult(showSound,1);
}
I set tts to read a sentece from Im_SensShow.java and when I press the button in Im_SensShow.java page this progarm change to tts page and make sound
but actually I want it to send only sentence and doesn't change page (stay in Im_SensShow.java page)
I try to not declare .Tts in Manufest but it force close What should I do?
Put the tts.speak()
call in a [onItemClick()][1]
listener.
You need to make sure that the TTS subsystem is already initialized (e.g. within onCreate()
of your Im_SendShow activity).