So, if we attach, we have to disconnect the stream after it finishes, right?
JNIEnv* get_jni_env() { JNIEnv* res; JAVA_VM->GetEnv((void**) &res, JNI_VERSION_1_6);
I call the following native method from @Override protected void onDestroy () of my Activity class
void free_jni_manager() { JNIEnv* env = get_jni_env(); ...
ERROR: disconnecting stream with interpolation frames (count = 16) - the main stream is still working, and we are trying to disconnect it.
Even if we take any function using JNIEnv (for example, calling java methods), setting DetachCurrentThread will result in the same error.
DetachCurrentThread works flawlessly if used in the pthread function
static void* thread_func(void* arg) { get_jni_env();
Do we need to disconnect the main thread, and we did it with JNI, yes? Or then the activity will be destroyed, it will be freed from JavaVM? Do we need to call DestroyJavaVM () (just crash when using onDestroy), how to handle this free JavaVM caching or garbage cleaner?
PS What are the benefits of using AttachCurrentThreadAsDaemon ()
source share