IntentNotFoundException for TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA

I am trying to translate text into speech by following this article on the Android Developers Blog. It offers the following code for setting text data if it is not supported.

Intent installIntent = new Intent(); installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); startActivity(installIntent); 

This throws an Exception :

ActivityNotFoundException : no activity found to handle intent

However, I use the code here to determine that intent is actually supported. Here is the list:

 [ResolveInfo{43cc5280 com.svox.pico.DownloadVoiceData p=0 o=0 m=0x108000}] 

Why is this not working?

Update

I don’t know why, but now it works.

+4
source share
2 answers

To check if intent is actually supported, use the following code:

 PackageManager pm = getPackageManager(); Intent installIntent = new Intent(); installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); ResolveInfo resolveInfo = pm.resolveActivity( installIntent, PackageManager.MATCH_DEFAULT_ONLY ); if( resolveInfo == null ) { // Not able to find the activity which should be started for this intent } else { startActivity( installIntent ); } 

If it cannot find the action using resolveActivity (), then this action requires other parameters that are not provided. In this case, you should get the class name using queryIntentActivities () and set the component name / class of intent.

+6
source

In which version of the Android SDK do you target your code? Remember that TTS is only available from 1.6 (SDK Level 4) onwards. This code works fine with 2.0 (SDK Level 5).

 <uses-sdk android:minSdkVersion="5" /> 
0
source

Source: https://habr.com/ru/post/1309076/


All Articles