Unfortunately, TextToSpeech.Engine
is declared non-static which means something like this:
public class TextToSpeech {
public class Engine {
// ...
}
// ...
}
So according to this, you can't access it. Here's my workaround using a wrapper:
object ConstantsWrapper {
private val cls = classOf[TextToSpeech#Engine]
def apply(fieldName: String) = cls.getDeclaredField(fieldName).get(null)
.toString
val CHECK_VOICE_DATA_PASS = apply("CHECK_VOICE_DATA_PASS")
// Insert more here
}
if (resultCode == ConstantsWrapper.CHECK_VOICE_DATA_PASS) {
mTts = new TextToSpeech(this, mTtsListener)
}