Skip to content Skip to sidebar Skip to footer

How To Show Up The Settings For Text To Speech In My App?

I have an application which uses the tts engine in Android, now as the activity starts, I want to show to the users the settings present in the phone for the tts engine in which th

Solution 1:

For ICS users Bandreid's call won't work anymore. You have to use this code:

intent = newIntent();
intent.setAction("com.android.settings.TTS_SETTINGS");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);

Solution 2:

I had the same problem for my app and found this post. I managed to do it by myself so this answer is for those who might need it as well.

ComponentNamecomponentToLaunch=newComponentName(
        "com.android.settings",
        "com.android.settings.TextToSpeechSettings");
Intentintent=newIntent();
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(componentToLaunch);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

We create an explicit intent, and we have to launch the com.android.settings.TextToSpeechSettings component. You can use LogCat in eclipse to find whatever package or component you are trying to launch. Just look at the ActivityManager's Starting activity messages and you will see the package and component name of any Activity.

UPDATE

As of Android ICS you should use the solution that the Force posted below.

intent = newIntent();
intent.setAction("com.android.settings.TTS_SETTINGS");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);

Solution 3:

I have merged Bandreid's and Force's answer to support every Android Version.

Use this code:

//Open Android Text-To-Speech Settingsif (Build.VERSION.SDK_INT >= 14){
    Intentintent=newIntent();
    intent.setAction("com.android.settings.TTS_SETTINGS");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
}else {
    Intentintent=newIntent();
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setComponent(newComponentName("com.android.settings", "com.android.settings.TextToSpeechSettings"));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
}

Or in one line:

//Open Android Text-To-Speech SettingsstartActivity(Build.VERSION.SDK_INT >= 14 ?
        new Intent().setAction("com.android.settings.TTS_SETTINGS").setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) :
        new Intent().addCategory(Intent.CATEGORY_LAUNCHER).setComponent(new ComponentName("com.android.settings", "com.android.settings.TextToSpeechSettings")).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));

Hope my answer help!

Solution 4:

Create an Intent to open the settings. I think it would be.

Intenti=newIntent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS);
startActivityForResult(i); // to come back to your activity.

Post a Comment for "How To Show Up The Settings For Text To Speech In My App?"