You can verify this by first sending the intent to the result
Intent intent = new Intent();
intent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(intent, 0);
Then you can verify that if you installed the TTS engine or not in the onActivityResult method:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 0){
if(resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS){
Toast.makeText(getApplicationContext(),"Already Installed", Toast.LENGTH_LONG).show();
} else {
Intent installIntent = new Intent();
installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installIntent);
Toast.makeText(getApplicationContext(),"Installed Now", Toast.LENGTH_LONG).show();
}
Hope it works :)
source
share