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?

2
  • Did you try "com.android.settings.tts.TextToSpeechSettings" instead? Aug 26, 2012 at 22:08
  • BillTheApe Thanks. Yes, I tried with the .tts. inserted in between, too, but that didn't help.
    – uTubeFan
    Aug 26, 2012 at 23:00

1 Answer 1

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);
1
  • 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 is right: There's no way to launch an intent if it's not same exact package?
    – uTubeFan
    Aug 26, 2012 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.