diff --git a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp index 72470e69c7..cb1a76f5d5 100644 --- a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp +++ b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp @@ -42,7 +42,7 @@ extern "C" { cocos2d::Director::getInstance()->mainLoop(); } - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause(JNIEnv* env) { if (Director::getInstance()->getOpenGLView()) { Application::getInstance()->applicationDidEnterBackground(); cocos2d::EventCustom backgroundEvent(EVENT_COME_TO_BACKGROUND); @@ -50,7 +50,7 @@ extern "C" { } } - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() { + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume(JNIEnv* env) { static bool firstTime = true; if (Director::getInstance()->getOpenGLView()) { // don't invoke at first to keep the same logic as iOS @@ -75,11 +75,9 @@ extern "C" { cocos2d::IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); } - JNIEXPORT jstring JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeGetContentText() { - JNIEnv * env = 0; - - if (JniHelper::getJavaVM()->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK || ! env) { - return 0; + JNIEXPORT jstring JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeGetContentText(JNIEnv* env) { + if (! env) { + return nullptr; } std::string pszText = cocos2d::IMEDispatcher::sharedDispatcher()->getContentText(); return cocos2d::StringUtils::newStringUTFJNI(env, pszText); diff --git a/extensions/scripting/lua-bindings/manual/platform/android/jni/Cocos2dxLuaJavaBridge.cpp b/extensions/scripting/lua-bindings/manual/platform/android/jni/Cocos2dxLuaJavaBridge.cpp index dbd52eeaea..e617704187 100644 --- a/extensions/scripting/lua-bindings/manual/platform/android/jni/Cocos2dxLuaJavaBridge.cpp +++ b/extensions/scripting/lua-bindings/manual/platform/android/jni/Cocos2dxLuaJavaBridge.cpp @@ -37,16 +37,14 @@ extern "C" { -JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaFunctionWithString - (JNIEnv *env, jclass cls, jint functionId, jstring value) +JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaFunctionWithString(JNIEnv *env, jclass cls, jint functionId, jstring value) { std::string strValue = cocos2d::StringUtils::getStringUTFCharsJNI(env, value); int ret = LuaJavaBridge::callLuaFunctionById(functionId, strValue.c_str()); return ret; } -JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaGlobalFunctionWithString - (JNIEnv *env, jclass cls, jstring luaFunctionName, jstring value) +JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaGlobalFunctionWithString(JNIEnv *env, jclass cls, jstring luaFunctionName, jstring value) { std::string functionNameStr = cocos2d::StringUtils::getStringUTFCharsJNI(env, luaFunctionName); std::string valueStr = cocos2d::StringUtils::getStringUTFCharsJNI(env, value); @@ -55,14 +53,12 @@ JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_callLuaGlobal return ret; } -JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_retainLuaFunction - (JNIEnv *env, jclass cls, jint luaFunctionId) +JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_retainLuaFunction(JNIEnv *env, jclass cls, jint luaFunctionId) { return LuaJavaBridge::retainLuaFunctionById(luaFunctionId); } -JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_releaseLuaFunction - (JNIEnv *env, jclass cls, jint luaFunctionId) +JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxLuaJavaBridge_releaseLuaFunction(JNIEnv *env, jclass cls, jint luaFunctionId) { return LuaJavaBridge::releaseLuaFunctionById(luaFunctionId); }