Convert JNI types to Native types
You just need to cast jint
to int
using C style casts. Same for jboolean
to bool
(if you're using C99 bool
type) or to uint8_t
(if you're using std int types) or to unsigned char
.
Open $NDK_ROOT/platforms/android-8/arch-arm/usr/include/jni.h
and you'll see jint
, jboolean
etc are just typedef
s.
To cast a jboolean
(which may only contain the values JNI_FALSE
or JNI_TRUE
) to a native bool
I would use something like this :
(bool)(jboolean == JNI_TRUE)
If perhaps the jboolean
isn't coming from the JVM, then testing for jboolean != JNI_FALSE
might be considered safer.