Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show up the settings for text to speech in my app?

Tags:

android

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 they can change the pitch, test the engine, etc which is already present in the emulator.

So, how do I present to them this screen?

like image 644
pranay Avatar asked Jul 01 '10 18:07

pranay


People also ask

How do I use text-to-speech app?

To enable that, go to Settings > Accessibility > Select-to-speak. To use it, select text in any app and choose Speak from the popup menu. If you only want basic text-to-speech functionality, you can stop here.


4 Answers

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

intent = new Intent();
intent.setAction("com.android.settings.TTS_SETTINGS");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
like image 198
Force Avatar answered Nov 04 '22 12:11

Force


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.

ComponentName componentToLaunch = new ComponentName(
        "com.android.settings",
        "com.android.settings.TextToSpeechSettings");
Intent intent = new Intent();
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 = new Intent();
intent.setAction("com.android.settings.TTS_SETTINGS");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
like image 36
Bandreid Avatar answered Nov 04 '22 12:11

Bandreid


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

Use this code:

//Open Android Text-To-Speech Settings
if (Build.VERSION.SDK_INT >= 14){
    Intent intent = new Intent();
    intent.setAction("com.android.settings.TTS_SETTINGS");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
}else {
    Intent intent = new Intent();
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setComponent(new ComponentName("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 Settings
startActivity(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!

like image 20
Thomas Vos Avatar answered Nov 04 '22 11:11

Thomas Vos


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

Intent i = new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS);
startActivityForResult(i); // to come back to your activity.
like image 2
Robby Pond Avatar answered Nov 04 '22 11:11

Robby Pond