java代码
private static String getString(){
return string;
}
C++代码
static string getDeviceModelJNI() {
string retValue = "";
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
JniMethodInfo minfo;//定义Jni函数信息结构体
jstring jobj;
bool isHave = JniHelper::getStaticMethodInfo(minfo,"com/wangniu/hlddz/SGddzActivity","getDeviceModel", "()Ljava/lang/String;");
if (isHave) {
jobj = (jstring)minfo.env->CallStaticObjectMethod(minfo.classID, minfo.methodID);
}
retValue = JniHelper::jstring2string(jobj);
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
retValue = "MAC";
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
retValue = "Win32";
#endif
return retValue;
}
};