7 package com.google.appinventor.components.runtime.util;
12 import android.app.Activity;
13 import android.content.Intent;
14 import android.speech.tts.TextToSpeech;
16 import java.util.Locale;
31 private static final String TTS_INTENT =
"com.google.tts.makeBagel";
35 private int requestCode;
43 this.container = container;
44 this.callback = callback;
48 public void speak(String message, Locale loc) {
49 Intent intent =
new Intent(TTS_INTENT);
50 intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
51 intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
52 intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
53 intent.putExtra(
"message", message);
54 intent.putExtra(
"language", loc.getISO3Language());
55 intent.putExtra(
"country", loc.getISO3Country());
56 if (requestCode == 0) {
59 container.
$context().startActivityForResult(intent, requestCode);
89 boolean isSuccess = (requestCode == this.requestCode) && (resultCode == Activity.RESULT_OK);
100 return TextToSpeech.LANG_MISSING_DATA;