我在这一行得到一个 SIGNAL 11:
// Call bool isInternetConnection()
jboolean jReturnValue = env->CallBooleanMethod(mClass,mid);
在这段代码中:
/**
* Check if Internet Connection is ONLINE
*/
bool InterfaceJNI::isInternetConnected()
{
JavaVM* jvm = JniHelper::getJavaVM();
int status;
JNIEnv *env;
jmethodID mid;
bool isAttached = false;
bool returnValue = false;
CCLog("InterfaceJNI isInternetConnected");
// Get Status
status = jvm->GetEnv((void **) &env, JNI_VERSION_1_6);
if(status < 0)
{
CCLog("isInternetConnected Status < 0 Failed to get JNI Enviroment!!!");
status = jvm->AttachCurrentThread(&env, NULL);
CCLog("isInternetConnected Status 2: %d", status);
if(status < 0)
{
CCLog("isInternetConnected Status < 0 !!!");
return false;
}
isAttached = true;
CCLog("isInternetConnected Status isAttached: %d", isAttached);
}
CCLog("isInternetConnected Status: %d", status);
CCLog("isInternetConnected Finding Class....");
jclass mClass = env->FindClass("org/example/SocialNetwork/CCSocialNetwork");
// Get Static bool isInternetConnection()
CCLog("isInternetConnected Getting method....");
mid = env->GetMethodID(mClass, "isInternetConnection", "()Z");
if (mid == 0)
{
CCLog("isInternetConnected FAIL GET METHOD STATIC");
return false;
}
CCLog("isInternetConnected Calling method....");
// Call bool isInternetConnection()
jboolean jReturnValue = env->CallBooleanMethod(mClass,mid);
CCLog("Call done ");
// Convert value from Java to C++
returnValue = (bool)jReturnValue;
CCLog("isInternetConnected Done ");
if(isAttached)
jvm->DetachCurrentThread();
// Change for return value
return returnValue;
}
但我不知道为什么。如果我使用“()V”进行 void 调用工作正常,但是当我尝试调用返回 bool no 的函数时。
到底是怎么回事?