I am using the TTS in my Activity. I Want the tts dialog appear only one time.
答案 0 :(得分:1)
您可以使用共享偏好。假设您定义了一个布尔值,在选择要使用的TTS时将其设置为true并保存到共享首选项。下次运行应用程序时,您应检查所述布尔值,并仅在对话框为false时启动该对话框。
示例:
private SharedPreferences preferences;
private String PREFS_NAME = "com.example.stackoverflow";
private String PREFS_CHECK = "com.example.stackoverflow.check";
private Boolean check;
preferences = this.getSharedPreferences(PREFS_NAME,MODE_PRIVATE);
check = preferences.getInt(PREFS_CHECK_STATS,false);
if(check){
.
.
.
}else{
.
.
.
preferences.edit().putBoolean(PREFS_CHECK,true).commit(); //Here you set the value.
}