4

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?

Community
  • 1
  • 1
uTubeFan
  • 6,664
  • 12
  • 41
  • 65
  • Did you try "*com.android.settings.[tts](http://code.google.com/p/android/issues/detail?id=22355).TextToSpeechSettings*" instead? – Bill The Ape Aug 26 '12 at 22:08
  • BillTheApe Thanks. Yes, I tried with the `.tts.` inserted in between, too, but that didn't help. – uTubeFan Aug 26 '12 at 23:00

1 Answers1

3

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);
Community
  • 1
  • 1
ef2011
  • 10,431
  • 12
  • 49
  • 67
  • Sounds promising, but how to I launch this from inside the preferences XML??? I tried creating my own PreferenceActivity that calls this code, but I still get the same exception (only now with my own activity instead of the `com.android.settings.TextToSpeechSettings`). Looks like [@ehartwell](http://stackoverflow.com/a/10888411) is right: There's no way to launch an intent if it's not same exact package? – uTubeFan Aug 26 '12 at 23:05