Hooking Java code into Android JUCE Apps - how do people do it?


#1

I'm trying to do a few things that require me to write code in Java and hook it into the app, such as use Bluetooth, write to the camera roll, etc.

I understand something called the "JNI" is required to do this, but I don't really understand much about it yet.

The actual Android documentation is very clear that one should not use the NDK to write apps exclusively and minimize the use of it, but obviously we've taken the plunge here in JUCEland, and that's fine.

So assuming that's what we want to do, there are going to be times when it's required for us to go back into JavaWorld to accomplish certain things and hook it back into the JUCE code somehow.

I believe that there are some people here who have had success using the JNI and perhaps other things. The problem is, I don't really know how to approach this from a best practices standpoint. What's the basic approach to doing this? Where should I write my Java code, how do I somehow write a C++ wrapper for it, and then how do I call that using JUCE?

Even just a basic recipe that works would be extremely helpful! I'll make my own best practices if all else fails.


#2

The JNI is pretty horrible to use - I obviously use it a lot inside the juce implementation, and I wrote a lot of macros and helper classes for it, but it's still not much fun. It's way too complicated to expect anyone to give you a quickstart guide here, but there are plenty of tutorials about it out there.


#3

OK, thanks. This at least confirms the JNI is the thing I need to be looking into.