-2

I tried it, but failed. Is this possible ? If not, how do you create similar connection/hold-tight screen ?

J. Doe
  • 75
  • 1
  • 9

2 Answers2

0

You can only use it from Java layer. Try surface the data from JNI to java, and use it in the activity.

xuguo
  • 1,816
  • 1
  • 11
  • 15
  • I understand TangoUX can only be used in java layer. I already have a workable app accessing TangoService, and rendering in JNI, but I want to add UI like the TangoUX which can indicate the user about the Tango status. What I have tried is: setup and run tangoUX in activity as this official java example, and meanwhile continue to use JNI to access TangoService as in the official c example. It seems TangoUX doesn't work normally in such a setup. – J. Doe Jul 27 '16 at 09:54
0

Yes It's possible, but not straight forward.

As Jason Guo said, you have to get the necessary information from the C API and send it back to the Java TangoUx via the JNI.

Basically, in your TangoService callback (C) functions you need to call the appropiate TangoUX function (java):

  • TangoService_connectOnXYZijAvailable -> mTangoUx.updateXyzCount
  • TangoService_connectOnPoseAvailable -> mTangoUx.updatePoseStatus
  • TangoService_connectOnTangoEvent -> mTangoUx.updateTangoEvent

For that, you have to see how JNI is used to call java functions: http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html

Be careful because the C callbacks are not executed in the main java thread. So you need to update the JNIEnv in each callback (using the JavaVM class). This link have some useful information although it uses an old version of the JNI. http://android.wooyd.org/JNIExample/files/JNIExample.pdf

Daniel GL
  • 1,229
  • 11
  • 24