android async
Monkey Targets Forums/Android/android async
| ||
Hi I've been playing with getting images form the camera into Monkey. I can get the camera called and the take the picture, but due to the way Money is synchronous I don't seem to be able to get the image into Monkey. The camera code is asynchronous and requires startActivityForResult to start the camera intent and the result will be in onActivityResult. unfortunately I can't seem to pause the monkey code until i have a result therefore the function to call the camera ends as soon as startActivityForResult is called. Has anyone tried pausing until there is a result? I've tried alsorts while (cameraIntent.getExtras()==null) { try { Thread.sleep(100); // do nothing for 100 miliseconds } catch(InterruptedException e) { e.printStackTrace(); } } |
| ||
Hmm... as you need the native part anyway wouldn't it be possible to have a flag on the native side and a function where you get that flag on the monkey side of the code? Pseudo code native part: class camera { // this is your helper function which should be in Monkey as well bool _resultReady; public static bool GetResultReady() { return _resultReady; } // this is your callback void onActiviyResult() { // something happens here... _resultReady = true; } } Monkey part: Import "native/camera.${TARGET}.${LANG}" Extern Class Camera = "Camera" Method GetResultReady:Bool() End Class Or you do it the "right" way and implement callbacks in Monkey as well. So you would expand the Monkey part like: Import "native/camera.${TARGET}.${LANG}" Extern Class Camera = "Camera" Method GetResultReady:Bool() Method OnActivityResult:Void() Abstract End Class ...and just implement the Callback. Should work... |