I’m trying to integrate https://gist.github.com/emil2k/5130324 this to use in c++ code. I tried http://stnguyen.com/cocos2d-x/call-java-functions-from-cpp.html this but getting compilation error. Can anybody explain how to do it briefly?
Here’s the error log:
error: 'JniMethodInfo' is not a member
of 'cocos2d'
cocos2d::JniMethodInfo t;
…\proj.android\src\com\emil\android\util\Connectivity.java is the path of the class.
cocos2d::JniMethodInfo t;
bool returnValue = false;
JniHelper::getStaticMethodInfo(t, "com/emil/android/util/Connectivity", "isConnected", "()Z");
jboolean jReturnValue = t.env->CallStaticBooleanMethod(t.classID, t.methodID);
returnValue = (bool)jReturnValue;
t.env->DeleteLocalRef(t.classID);
Now the class is not found.
#include "jni.h"
#include "platform/android/jni/JniHelper.h"
bool checkConn = false;
cocos2d::JniMethodInfo t;
if (cocos2d::JniHelper::getStaticMethodInfo(t, "com/emil/android/util/Connectivity",
"isConnected", "()Z")) {
jboolean result = t.env->CallStaticBooleanMethod(t.classID, t.methodID);
if (result == JNI_TRUE) {
checkConn = true;
} else {
checkConn = false;
}
}
if(checkConn){
log("baglanti: connected");
}else{
log("baglanti: not connected");
}
This always returns false(not connected).