I have read stuff about how to wrap things to be backward compatible but I can't get my arms around this one
I would like to do
TextToSpeech textToSpeech = ...
...
if(Build.VERSION.SDK_INT >= 15){
textToSpeech.setOnUtteranceProgressListener(new UtteranceProgressListener() {
...
});
}
the problem is UtteranceProgressListener is api >= 15. I am targeting api 8 (I work for someone, I can't change this)
I was thinking of using Class.forName(...)
but if I do that the code cannot compile (it is expecting a listener of type UtteranceProgressListener
)
And if I do it, how can I implement the methods @Override
of an object that is defined by a string ? At compile time Java doesn't know about them, right ?