我有一个活动,它使用文本到语音引擎大声说出给定的文本。这里是:
public class AfterPassword extends Activity implements OnInitListener {
private TextToSpeech tts;
private String message = "This message will be spoken out.";
static final int TTS_CHECK_CODE = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.afterpassword);
tts = new TextToSpeech(this, this);
}
@Override
public void onInit(int initStatus) {
if (initStatus == TextToSpeech.SUCCESS) {
tts.speak(message, TextToSpeech.QUEUE_FLUSH, null);
}
}
}
我面临的问题是,当讲话结束时,偶然用户改变了屏幕方向,讲话又开始了。我想停止谈论方向变化。