Hey,
I have few issues concerning graphic interface. I would like to change a TextView depending on the image tracked (with ImageTargets sample).
I've added a GUIManager as in VirtualButton & this works fine.
However, i want to change a text from a TewtView (from the GUIManager) depending on what is currently tracked.
I have tried to add the GUIManager object to the renderer &, in the function onDrawFrame, I tried mGUIManager.updateText(), but i receive "callfromWrongThreadException" exception (which I understand).
However, i don't know how to fix this, maybe create an event in the renderer thread which tells the main thread each time the function onDrawFrame is called, but I don't manage to do it ( I don't know how to do this..).
Thanks by advance for your time.
Good. You can use that same approach, by implementing a handler to call across threads, for more sophisticated updating of views as well.
In the Android samples, most native methods can be divided into two categories: those called from the main ( aka UI ) thread and those called from the GL thread. In ImageTargets.cpp, for example, any method that starts with Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer is called from the GL thread. These methods are called from the onSurfaceCreated, onSurfaceChanged, or onDrawFrame callback methods in ImageTargetsRenderer.java, which are called by Android on a separate OpenGL thread. Most of the methods that start with Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets are called from the main thread. One exception is the loadTrackerData method, which is called from an AsyncTask in ImageTargets.java.