1

I'm defining a callback to process audio in Android using Superpowered SDK. I'm passing the JNIEnv using the clientData pointer in the callback. Is there anyway I can call a simple Java function to update some text on the main screen inside the callback?

My code is built on the FrequencyDomain example for Superpowered SDK.

Abhishek Sehgal
  • 590
  • 4
  • 16

1 Answers1

1

This question is not related to Superpowered, but JNI: Java Native Interface.

You can call Java from native code, but it's quite complex (and ugly).

Check "Calling Java code from C/C++ programs" in this article by IBM: http://www.ibm.com/developerworks/java/tutorials/j-jni/j-jni.html

Gabor Szanto
  • 1,329
  • 8
  • 12
  • 1
    Hey Gabor! So what I did was, created a Runnable in the MainActivity that calls a C++ function every second to update the GUI. Since the update just requires an integer value from the output of the process this was easy. The other part was to save the output as a text file. I was able to achieve this using file functions in C++. I did read the link you sent me and it was ugly. And it was even more difficult as the function that I was trying to use to update the GUI was a callback in C++ which had no access to JNIEnv or jobject. – Abhishek Sehgal Dec 03 '16 at 01:05