android - Show up the settings for text to speech in my app -


i have implemented tts support reading text strings in application, , works fine. want achieve is, user able open preferences tts , can make changes according his/her wish.

here's code

intent intent = new intent(); intent.setaction("com.android.settings.tts_settings"); intent.setflags(intent.flag_activity_new_task); detailactivity.this.startactivity(intent); 

but app crash when running code. i'm using android 4.1.2 device.

anyone suggestions?

thanks in advance.

you may use intent action check tts preference

private void checkttsavailability() {     intent checkttsintent = new intent();     checkttsintent.setaction(texttospeech.engine.action_check_tts_data);     startactivityforresult(checkttsintent, tts_data_check_code); } 

and handle result on onactivityresult(int requestcode, int resultcode, intent data)

    if(requestcode == tts_data_check_code){         // success! file has been installed         if(resultcode == texttospeech.engine.check_voice_data_pass){             mtts = new texttospeech(getactivity(), this);         }else{             // fail, attempt install tts             intent installtts = new intent();             installtts.setaction(texttospeech.engine.action_install_tts_data);             startactivity(installtts);         }     } 

or if want open settings use action

intent intent = new intent(); intent.setaction("com.android.settings.tts_settings"); intent.setflags(intent.flag_activity_new_task); this.startactivity(intent); 

about crash because of ics (api >= 14), use solution above ics , up.


Comments