Hi,
Cool app! You can add a new target for Android in Projucer, which will generate Android Studio project for you.
All the main communication between Java and C++ is done for you already in JUCE. If you then need to do additional Java calls (like your native UI), you need Java Native Interface: https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaNativeInterface.html
Using JNI you can call native C++ functions from Java and from C++ you can call Java too. The skeleton for Java is in JuceAppActivity.java
that will be copied to your project and named after your project name. Some of the content of the file is generated during saving, which is why the file gets overwritten every time you save a project. Hence you will want to add all the code (including creation of Java native views) from C++. If you needed to add custom stuff to your manifest (~plist sort of equivalent on Android), Projucer allows you to customise any content of the manifest, that will override any default value. You will find quite a few Android specific settings in Projucer. You should be able to avoid the need of adding any Java code in majority of the cases.
While it is not officially exposed, in JUCE land there is AndroidSystem android
global variable and android.activity
member is the Activity
from Java land you can work with. So if any of your Java classes requires Context
, you can pass android.activity.get()
. Lastly, JUCE has a very handy macro JNI_CLASS_MEMBERS
which is used to declare a Java class that you will call in C++. This allows to avoid all sort of tedious code dealing with finding method and field IDs (more on that in JNI tutorial above).
I don’t know what your strategy with embedding native views is, one way to do it is to use JUCE’s AndroidViewComponent
(on iOS it is UIViewComponent
). You should be able to find examples on how we talk to Java in lots of places in JUCE while WebBrowserComponent
implementations will show you how to use AndroidViewComponent
and UIViewComponent
.
I hope that helps.