0

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 ?

Thomas
  • 8,306
  • 8
  • 53
  • 92

1 Answers1

0

Open up your androidmanifest.xml. Change your min api to 8. Make sure you update android api 8 using android tool.

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
Nurdin
  • 23,382
  • 43
  • 130
  • 308