call a Java function. It works fine!
But, when I call a Native function from this called Java function
(Native pthread->Java function->Native), then I got an app crash.
Why? And what can I do against this crash?
// * Called from Java onCreate() *
int startThread() {
if ((*vm)->GetEnv(vm, (void**)&jni_env, JNI_VERSION_1_6)){
return;
}
java_classname = (*jni_env)->FindClass(jni_env, "com/x/y/ZService");
if(java_classname == NULL) return 0;
javaMethod_javaEvent = (*jni_env)->GetMethodID(jni_env,
java_classname,"javaEventFunction", "(IIII)V");
if(javaMethod_javaEvent == NULL)return 0 ;
pthread_create(&realEventThread, NULL, getRealEvents, NULL);
return 1;
}
void *getRealEvents( void *ptr ) {
JNIEnv *env;
(*vm)->AttachCurrentThread(vm, &env, 0);
usleep (1000000);
while(isRunning == true) {
usleep (200000);
(*env)->CallVoidMethod(env, java_classname, javaMethod_javaEvent);
}
(*vm)->DetachCurrentThread(vm);
}
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment