The default LuaLoader class from the Android template includes a show() method that creates a webView and adds to the Corona activity, so I’m building my own plugin based on this same approach to get a camera surface view onto the activity. e.g:
public class start implements com.naef.jnlua.NamedJavaFunction { // This reports a class name back to Lua during the initiation phase. @Override public String getName() { return "start"; } // This is what actually gets invoked by the Lua call @Override public int invoke(final LuaState luaState) { if(shared.status != "running") { shared.status = "running"; CoronaActivity activity = CoronaEnvironment.getCoronaActivity(); if (activity == null) { return 0; } activity.runOnUiThread(new Runnable() { @Override public void run() { CoronaActivity activity = CoronaEnvironment.getCoronaActivity(); if (activity == null) { return; } cameraPreview mPreview = new cameraPreview(activity); activity.getOverlayView().addView(mPreview); } }); } return 1; } }
(obviously cameraPreview is another class)
Seems to work perfectly, but I can’t find how to remove the surface again? Or potentially better yet, to clear the OverlayView completely. Any pointers please?