Here's how I get a list of installed engines, their labels and package
names. I use this list to populate a preference allowing the user to
pick. This is Scala code, but hopefully it's still clear:
val intent = new Intent("android.intent.action.START_TTS_ENGINE")
val pm = getPackageManager
val engines = pm.queryIntentActivities(intent, 0).map { engine =>
var label = engine.loadLabel(pm).toString()
if(label == "") label = engine.activityInfo.name.toString()
(label, engine.activityInfo.packageName)
}
val enginesPreference =
findPreference("speechEngine").asInstanceOf[ListPreference]
enginesPreference.setEntries(engines.map(_._1).toArray[CharSequence])
enginesPreference.setEntryValues(engines.map(_._2).toArray[CharSequence])
Basically, fire off the intent, calculate a label for each package, then
create a List of Tuples of the form (label, package). Then, find the
preference, populating its entries with all the labels and its values
with the package names such that selecting the label sets the preference
to the correct package.
Hope that helps. Not sure if some of the casts are necessary, but the
intersection of Java and Scala collections seems a bit hazy in
places--to me, at least.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAky7M94ACgkQIaMjFWMehWKYDgCdHk8Fyu7r0USw4bwz5wDDfoCl
OmUAn1COh3hkI+bKI2vnL0f7WiDOBA2J
=j/E1
-----END PGP SIGNATURE-----