How to execute Java (Android) code from C++
I am wondering how I could access images in my Android game. Basically, the functionality I need is that through a click of a UMG button, the Androids' image gallery pops up and the user can pick an image from there.
I did the same thing in iOS (see this thread). Using iOS, I could create a cpp file and put my Objective-C code in there. I also needed to run my methods on the iOS main thread.
Using Android, I don't really know how to start. Looking at the
I noticed that I probably would need to use JNI and read about it in the Android docs. I created a new Java file and placed in
What would be the steps to get this going? Even the slightest hint can help...
asked Mar 25 '15 at 03:02 PM in Using UE4
The way we call in to Java from C++ is almost all inside of AndroidJNI.cpp. Search for "ShowConsoleWindow" in that file for all the bits needed to add new functions to be called, and even passing parameters in to Java code.
answered Mar 25 '15 at 07:28 PM
See attached WIP library for popping up a keyboard and getting text changes back from an invisible EditText component. Should show you how to run a C++ -> Java interface.
I'd remove the C style intermediate functions, they just add indirection (I copied the style when learning to setup C++ -> Java communication).
There are also functions defined in C that are called from Java - see:
This is declared in the Java (within the XML file) as:
Follow this question
Once you sign in you will be able to subscribe for any updates here