Skip to content

Instantly share code, notes, and snippets.

@yageek
Created August 16, 2017 13:04
Show Gist options
  • Save yageek/a105973cc2446cff9e27e61dfb7fba21 to your computer and use it in GitHub Desktop.
Save yageek/a105973cc2446cff9e27e61dfb7fba21 to your computer and use it in GitHub Desktop.
Android VM Settup (Qt inpired)
static JavaVM * m_android_vm = nullptr;
extern "C"
jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
__android_log_print(ANDROID_LOG_DEBUG, "TestBluetooth", "JNI LOAD");
static bool initialised = false;
if (initialised) {
return initialised;
}
initialised = true;
m_android_vm = nullptr;
typedef union {
JNIEnv *nativeEnvironment;
void *venv;
} UnionJNIEnvToVoid;
UnionJNIEnvToVoid venv;
JNIEnv *nativeEnvironment = nullptr;
if(vm->GetEnv(&venv.venv, JNI_VERSION_1_4) != JNI_OK){
__android_log_print(ANDROID_LOG_FATAL, "TestBluetooth", "GetEnv failed");
return -1;
}
return JNI_VERSION_1_6;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment