Android ”android.content.Context” and not the ”JmeContext”

Hi all, I’m very new to both game development and the JME platform and have a small question regarding JME running on an Android OS. My knowledge and experience is primarily creating business applications for Android so please bare with me.

I have managed to build a neat little game using JME’s supporting documentation and examples. The final functionality I need to implement is text to speech functionality provided by the Android api. I am able to create all the required objects and functionality by referencing the appropriate android.jar files. Unfortunately when I try to create a new instance of the TextToSpeech object, it requires I pass in a “Context”, this is the “android.content.Context” and not the “JmeContext” provided by JME’s “Application” class. So I guess my question is:

Is there anyway to get access to Android’s standard “android.content.Context” via the JME SDK? Or I guess if there was a way you could call a method in the class that extends the AndroidHarness, I could put the TextToSpeech implementation in there.

I have looked around but couldnt find any material. Thank you for any help, it is much appreciated.


Hmm, doesn’t seem like there’s a way to do this … You may need to store it in the AndroidHarness so it is available to the rest of the code.

You’ll need to create the TextToSpeech code in the Android project (ie. MainActivity) and pass the resulting data to the jME application via some sort of interface that you create.

Take a look at this. It isn’t the same issue, but it discusses how to pass Android specific information to the jME application.

Thanks for the help guys, I will give this approach a shot, this seems exactly what I need… Thanks :slight_smile: