Cocos2DX & JNI. How can I get NativeActivity?

Cocos2DX & JNI. How can I get NativeActivity?
0.0 0


Using SimpleAudioEngine, I’ve managed to get it compiled without errors but it fails to find my Class, I believe this is because I need to use the Native Class Loader, like below, but I don’t know how to obtain the Native Activity…

// get class and make it a global reference, release it at endJni().
static jclass getClassID(JNIEnv *pEnv)
// Find the Class through the NativeActivity
jobject nativeActivity = state~~>activity~~>clazz;
jobject nativeActivity = thiz;
jclass acl = pEnv~~>GetObjectClass;
jmethodID getClassLoader = pEnv~~>GetMethodID(acl, “getClassLoader”, “()Ljava/lang/ClassLoader;”);
jobject cls = pEnv~~>CallObjectMethod;
jclass classLoader = pEnv~~>FindClass(“java/lang/ClassLoader”);
jmethodID findClass = pEnv~~>GetMethodIDLjava/lang/Class;");
jstring strClassName = pEnv~~>NewStringUTF(“com/dunny/game/MyGame”);
jclass ret = (jclass)(pEnv~~>CallObjectMethod);
//jclass ret = pEnv~~>FindClass;
LOGD (“Failed to find class of %s”, CLASS_NAME);
return ret;
state~~>activity->clazz is the problematic line.

Can anyone help?



anyone know?


Have you added your new JNI files to cocos’s


Yes mate.