| 10 | //__android_log_vprint(ANDROID_LOG_ERROR,"MCServer", a_Format, argList); |
| 11 | |
| 12 | static void CallJavaFunction_Void_String( jobject a_Object, const std::string & a_FunctionName, const std::string & a_StringParam ) |
| 13 | { |
| 14 | JNIEnv * oldEnv = g_CurrentJNIEnv; |
| 15 | int status = g_JavaVM->AttachCurrentThread(&g_CurrentJNIEnv, NULL); |
| 16 | __android_log_print(ANDROID_LOG_ERROR,"MCServer", "STATUS: %i old: %p new: %p", status, oldEnv, g_CurrentJNIEnv ); |
| 17 | jstring str = g_CurrentJNIEnv->NewStringUTF( a_StringParam.c_str() ); |
| 18 | |
| 19 | |
| 20 | //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "JNIEnv: %i Object: %i", g_CurrentJNIEnv, a_Object ); |
| 21 | jclass cls = g_CurrentJNIEnv->GetObjectClass( a_Object ); |
| 22 | //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jclass: %i", cls ); |
| 23 | jmethodID mid = g_CurrentJNIEnv->GetMethodID( cls, a_FunctionName.c_str(), "(Ljava/lang/String;)V"); // void a_FunctionName( String ) |
| 24 | //__android_log_print(ANDROID_LOG_ERROR,"MCServer", "jmethodID: %i", mid ); |
| 25 | if (mid != 0) |
| 26 | { |
| 27 | |
| 28 | __android_log_print(ANDROID_LOG_ERROR,"MCServer", "Going to call right NOW! %s", a_FunctionName.c_str() ); |
| 29 | g_CurrentJNIEnv->CallVoidMethod( a_Object, mid, str ); |
| 30 | } |
| 31 | else |
| 32 | { |
| 33 | __android_log_print(ANDROID_LOG_ERROR,"MCServer", "It was 0, derp" ); |
| 34 | } |
| 35 | |
| 36 | if( oldEnv != g_CurrentJNIEnv ) |
| 37 | { |
| 38 | g_JavaVM->DetachCurrentThread(); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | |
| 43 | static void CallJavaFunction_Void_Void( jobject a_Object, const std::string & a_FunctionName ) |