Hey guys,

I nned your help. I am currently developing an application which uses
JNI and native sockets. The problem is that I have to call Java code
if some packages arrive on the native socket connection. Currently I
am using CallVoidMethod to do that. The JNIEnv cannot be cached so I
get it like this:

inline JNIEnv *get_env()
{
        JNIEnv *env;
        jvm->GetEnv((void **)&env, JNI_VERSION_1_4);
        return env;
}

The jmethodID I is cached and initialized on startup. My only problem
now is, how can I get the jobject? Currently I am making a global
reference on the parameter jobject thiz, which is passed to my init
function.

Is this okay? I am asking because I am having some trouble with that,
eg. the reference to the local and the global obj are exactly the
same. And when I a call DeleteGlobalRef on the global reference there
is a warning in the log cat output that this reference does not exist
and the app crashes.

I also tried using the local reference but then the CallVoidMethod
crashes and the output says this reference does not exist, so I think
I am on the right way.

Thanks in advance!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to