Hello, I am trying to write a cross platform module for Godot in C++, the Android C++ method takes the JNIEnv* and a pointer to the current activity as parameters? An idea how can I get them? In C++ code. I have seen use of them in Godot's files in the platform/android directory of Godot's source. but I couldn't figure out how to get them in my module code, thanks in advance!
Java + Android - How to get JNIEnv* and Activity object via C++
a month later
- Edited
Well, I have no idea if this is going to work because I never looked at these things, but form this https://developer.android.com/training/articles/perf-jni.html I gather you have to #incldue <jni.h>
which is where JNIEnv
is defined. This is a system include file, it's not in the godot source. Then you'll probably have to also #include "thread_jandroid.h"
which resides in GODOT_DIR/platform/android
, this is where ThreadAndroid
is defined and you get JNIEnv
with ThreadAndroid::get_env
function. As for the activity... I have no idea, I don't have time now to look at the source code for this, good luck!
6 years later
Megalomaniak added the Godot Help tag .