Android Question Using C++ code and AAudio API

jccordier

Member
Licensed User
Hello everybody.
I'd like to insert in my project some code from developers.google site (here). It's written in C++ and use the AAudio API.
It works fine as is. But how can I use it with B4A ?
Thanks for your advices.
 

JordiCP

Expert
Licensed User
Longtime User
You'll need to install the NDK and compile the code with it. This will produce binaries for the selected architectures.
Those functions in the C/C++ code that need to be accessed from Java will need a special syntax (JNI interface).
Depending on how complex the interface functions are, you'll need a small Java wrapper to access them. You could avoid this part, accessing the native calls with inline Java and some tricks but it is not advisable if you want to keep everything clean.

If you are new to the NDK, I recommend to start with a simple C function to learn how the whole process works. Once you feel comfortable with it, jump to the complex code


Or (just reminded now), you could also try with this TOOL made by @wonder some time ago. Not sure if it can be used with all kind of libs, or has any limitation (better check first)
 
Upvote 0

jccordier

Member
Licensed User
Thanks for the answer. The code I use relies on NDK and JNI. I just was wondering how I could use a MainActivity written with B4A, because it's so easy to manage the UI with it. It's a bit more tedious in Java or Kotlin. Just a question from a lazy guy !
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…