I am using the following technique to add the Text-to-Speech Settings
to my app's preference screen:
<Preference android:key="TTS Preferenes"
android:title="TTS Settings"
android:summary="A convenience shortcut instead of pressing HOME then Setting then scrolling down then pressing Text-to-Speech Settings">
<intent android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.TextToSpeechSettings" />
</Preference>
It works great in Android 2.x but in Android 4.0.4 in produces an exception:
E/AndroidRuntime(2663): android.content.ActivityNotFoundException:
Unable to find explicit activity class {com.android.settings/com.android.settings.TextToSpeechSettings};
have you declared this activity in your AndroidManifest.xml?
Why is this? What changed in Android 4 (or 3?) that makes this technique incompatible? Has the name of the system's TextToSpeechSettings preference screen changed?
Also, I am pretty sure is has nothing to do with the Manifest file, but to be on the safe side, I added to the Manifest:
<activity android:name="com.android.settings.TextToSpeechSettings"
android:label="Text-to-Speech Settings">
</activity>
And it didn't change a thing. Same ActivityNotFoundException problem.
In my search for an explanation, I found this thread, but it doesn't refer to any OS version differences, so I am not sure it applies here.
Any tip on why and how to solve this problem?
It appears that indeed this is an ICS issue as this answer suggests to use this code:
intent = new Intent();
intent.setAction("com.android.settings.TTS_SETTINGS");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);