axmol/tools/simulator/libsimulator/proj.android/hellolua/Runtime_android.cpp

22 lines
588 B
C++
Raw Normal View History

2015-01-07 17:50:15 +08:00
#include <jni.h>
#include <android/log.h>
#include "jni/JniHelper.h"
#include <string>
#include <vector>
using namespace std;
using namespace cocos2d;
string getIPAddress()
{
JniMethodInfo t;
string IPAddress("");
if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lua/AppActivity", "getLocalIpAddress", "()Ljava/lang/String;")) {
jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
t.env->DeleteLocalRef(t.classID);
IPAddress = JniHelper::jstring2string(str);
t.env->DeleteLocalRef(str);
}
return IPAddress;
}