Game Development Reference
In-Depth Information
if ( !jNativesCls ) {
jNativesCls = (*env)->FindClass(env, CB_CLASS);
if ( jNativesCls == 0 ) {
printf("Unable to find class: %s", CB_CLASS);
return;
}
}
// Call jni.Natives.OnMessage(String, int)
if (! mSendStr ) {
// Get aref to the static method: jni.Natives.OnMessage
mSendStr = (*env)->GetStaticMethodID(env, jNativesCls
, CB_CLASS_MSG_CB
, CB_CLASS_MSG_SIG);
}
if (mSendStr) {
// Call method
(*env)->CallStaticVoidMethod(env, jNativesCls
, mSendStr
, (*env)->NewStringUTF(env, text)
, (jint) level );
}
else {
printf("Unable to find method: %s, signature: %s\n"
, CB_CLASS_MSG_CB, CB_CLASS_MSG_SIG );
}
}
/**
* Printf into the Java layer
* does a varargs printf into a temp buffer
* and calls jni_sebd_str
*/
void jni_printf(char *format, ...)
{
va_list argptr;
static char string[1024];
va_start (argptr, format);
vsprintf (string, format,argptr);
va_end (argptr);
jni_send_str (string, 0);
}
/**
* Get Java array length
*/
const int getArrayLen(JNIEnv * env, jobjectArray jarray)
{
Search WWH ::




Custom Search