Callbacks from Android

I need to generate callbacks to Lua from within android plugin, going through the forum I can see some references but nothing that jumps out (to my very limited experience with android/java)

 

I recently wrote an Objective C library where I used the the following technique to allow callbacks to the Lua code from anywhere within the library

https://forums.coronalabs.com/topic/27486-ios-calling-lua-from-my-mm-module/

 

This has been working well, so now hope to implement similar in the Android version of our app being developed.

However, I can’t see how to go about it, all examples I can see return a result directly from a method called from lua, whereas I need to generate ad-hoc lua callbacks from within the plugin

 

Is there a solution to do this in android?

 

Scott

Have a look at Corona Enterprise sample project “SimpleLuaExtension”.  It contains several several examples on how to work with a Lua state in Java.  In particular, have a look at the “AsyncCallLuaFunction.java” file for an example on how to store Lua callback/listener and then call it asynchronously when finishing an operation from another thread.  The key thing to note here is that Corona and Lua does *not* run on the main UI thread.  That Java file I’ve mentioned will show you how to hop on to the main UI thread from the Lua thread… and then hop back onto the Lua thread when the task is completed.

Have a look at Corona Enterprise sample project “SimpleLuaExtension”.  It contains several several examples on how to work with a Lua state in Java.  In particular, have a look at the “AsyncCallLuaFunction.java” file for an example on how to store Lua callback/listener and then call it asynchronously when finishing an operation from another thread.  The key thing to note here is that Corona and Lua does *not* run on the main UI thread.  That Java file I’ve mentioned will show you how to hop on to the main UI thread from the Lua thread… and then hop back onto the Lua thread when the task is completed.