Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android文本到语音选择对话框仅一次_Android_Text To Speech - Fatal编程技术网

Android文本到语音选择对话框仅一次

Android文本到语音选择对话框仅一次,android,text-to-speech,Android,Text To Speech,例如:在屏幕截图中,假设我选择pico tts。当我下次打开此活动时。我不想让它下次开门 您可以使用SharedReference。假设您定义了一个布尔值,该值在选择要使用的TTS时设置为true并保存到共享首选项。下次运行应用程序时,您应该检查所述布尔值,只有当该值为false时才启动对话框 例如: I am using the TTS in my Activity. I Want the tts dialog appear only one time. private SharedPref

  • 例如:在屏幕截图中,假设我选择pico tts。当我下次打开此活动时。我不想让它下次开门

您可以使用SharedReference。假设您定义了一个布尔值,该值在选择要使用的TTS时设置为true并保存到共享首选项。下次运行应用程序时,您应该检查所述布尔值,只有当该值为false时才启动对话框

例如:

I am using the TTS in my Activity. I Want the tts dialog appear only one time.
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.
}