0
I am using the TTS in my Activity. I Want the tts dialog appear only one time.
- 例如:在屏幕拍攝假設我選擇微微TTS。當我下次開放這個活動。我不希望它會下一次打開
I am using the TTS in my Activity. I Want the tts dialog appear only one time.
你可以使用一個sharedpreference。假設您定義了一個布爾值,在選擇您要使用的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.
}