Desperate need for help!

Monkey Targets Forums/Android/Desperate need for help!

SLotman(Posted 2016) [#1]
I was fiddleing around with voice recognition on Android, using Google libs... I got it running pretty well on plain Java - but I'm having a HUGE problem on Monkey, which I don't know how to overcome :(

I ported my code from my Java project into a class, everything compiles fine but when I run it on Monkey, I get this error:

java.lang.RuntimeException: SpeechRecognizer should be used only from the application's main thread


I even tried making my whole class static - to no avail. If I call the methods on Main() - the setup at least works - but still, I can't access it anywhere else without getting the error above.
(So I cannot even start to listen to a voice command, without getting the same "run on main thread" error)

My code:


Monkey side:

There are more to the code, of course, but it is crashing right there, on createSpeechRecognizer. in the java code (when I call sRec.setup() in OnCreate.)

I have no idea on "how to "run this code in the main thread" - would I have to add my class into the main activity in the target java code? If so, how would I be able to call and retrieve results from it?

Any help deeply appreciated. I need to make a prototype of a game by Jan 10... and this is making me go crazy :/


SLotman(Posted 2016) [#2]
Nevermind, I figured it out. Had to make all code to be called like this:



Now it works :)