Run Java(Android) code from C++ using JNI

Hey guys,

I’m new to C++ programming but I can do Java and Android pretty decently. I know the bare basics of CPP but nothing more.

I knew you could write android in native code too but I never really got to learn it.

I’ve been using UE4 for some time now and trying to make my first game for android but blueprints lack some android functionalities that I would like to add in my game like -

  1. Orientation control.
  2. Sending intents
  3. Accessing android content providers.

So, I was looking through forums and answerhub to see useful stuff. I learnt about AndroidJNI but am very unclear on how to use it.

Some questions -

  1. Do I need UE4 Launcher or UE4 Source to make custom Java (Android) functions to be called from C++?
  2. Do I need to modify the GameActivity.java file in my Project folder or the Engine folder?
  3. How do I make a custom BP Node that calls the function created?

Please I would be really grateful if someone can provide a step by step guide for implementing this. By looking at the forums and answerhub it seems a pretty common thing.

Any simple example Like making an android Toast BP Function that says “Hello World”.
or makes a Toast with a String input provided.

It would be really amazing
Thankyou.

I was able to do it. By the help of MobileUtils Plugin by GameDNA Studios.

Hi, could you please help me with this?