获取安卓mac地址
public int testFun()
{
WifiManager wifiMgr = (WifiManager)getSystemService(Context.WIFI_SERVICE);

WifiInfo info = (null == wifiMgr ? null : wifiMgr.getConnectionInfo());

if (null != info)
{
macAddress = info.getMacAddress();
}

return 0;
}

public static String testFunWithInt()
{
System.out.println("mac:" + macAddress);

return macAddress;
}


#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include
#include "platform/android/jni/JniHelper.h"
#include
#endif

调用静态函数
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)

JniMethodInfo minfo;

bool isHave1 = JniHelper::getStaticMethodInfo(minfo,"com/soulgame/card/Card", "testFunWithInt", "()Ljava/lang/String;");

if (!isHave1)
{
CCLog("jni:此函数不存在");
}
else
{

std::string macId;

macId=JniHelper::jstring2string(jstring(minfo.env->CallStaticObjectMethod(minfo.classID, minfo.methodID)));

CCLog("macis is %s",macId.c_str());
}


#endif

调用非静态函数

JniMethodInfo methodInfo;//定义Jni函数信息结构体

//getStaticMethodInfo 次函数返回一个bool值表示是否找到此函数
bool isHave = JniHelper::getStaticMethodInfo(methodInfo,
"com/soulgame/tcweibo/tcweibo",
"getActivity",
"()Ljava/lang/Object;");
jobject jobj;

if (isHave)
{
jobj = methodInfo.env->CallStaticObjectMethod(methodInfo.classID, methodInfo.methodID);
}

CCLog("正确获取到 jobj");


isHave = JniHelper::getMethodInfo(methodInfo,
"com/soulgame/tcweibo/tcweibo",
"shardWeibo",
"()V");

if (isHave)
{
methodInfo.env->CallVoidMethod(jobj, methodInfo.methodID);
}


public static Activity actInstance;//定义单例

protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
actInstance=this;
}

public static Object getActivity()
{
return actInstance;
}



export ANDROID_SDK_ROOT=/Users/JaceLin/android/android-sdk-macosx-4/
export ANDROID_NDK_ROOT=/Users/JaceLin/android/android-ndk-r7$
export COCOS2DX_ROOT=/Users/JaceLin/android/cocos2d-2.0-x-2.0.3
export NDK_ROOT=/Users/JaceLin/android/android-ndk-r7
export A_NDK_ROOT=/Users/JaceLin/android/android-ndk-r7
export PATH=$PATH:/Users/JaceLin/android/android-ndk-r7
export PATH=$PATH:$ANDROID_SDK_ROOT
export PATH=$PATH:$ANDROID_NDK_ROOT
export PATH=/Users/JaceLin/android/android-sdk-macosx-4/platform-tools:$PATH
export PATH=/Users/JaceLin/android/android-sdk-macosx-4/tools:$PATH


(1)ndk-stack 调试命令使用方法
1、在工程目录下的jni文件夹下Application.mk中添加 APP_OPTIM := debug
2、在windows 下使用运行输入 cmd 进入 android-ndk 目录
3、运行命令 adb logcat | ndk-stack -sym d:\documents\project\inferno3\android\obj\local\armeabi\libgame_logic.so
或者adb logcat | ndk-stack -sym d:\documents\project\inferno3\android\obj\local\armeabi查看所有的*.so调试信息
查看文件ndk-native 调试信息

(2)使用模拟器运行Inferno 疯狂城堡额外操作方法
1、使用cmd 进入android-sdk的plafrom-tools目录
2、运行 emulator -partition-size 512 -avd your_avd_name





adb logcat | ndk-stack -sym /Users/JaceLin/android/cocos2d-2.0-x-2.0.3/sdk5/proj.android/obj/local/armeabi