diff --git a/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp b/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp index 32ccb21c..e1cb42bc 100644 --- a/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp +++ b/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp @@ -1,19 +1,23 @@ -#include "AppDelegate.h" -#include "cocos2d.h" -#include "platform/android/jni/JniHelper.h" -#include +#include + #include -#include "PluginJniHelper.h" +#include + +#include "platform/android/PluginJniHelper.h" + +#include "AppDelegate.h" #define LOG_TAG "main" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -using namespace cocos2d; +namespace { +std::unique_ptr appDelegate; +} -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init(JNIEnv* env) { LOGD("cocos_android_app_init"); - AppDelegate *pAppDelegate = new AppDelegate(); + appDelegate.reset(new AppDelegate()); JavaVM* vm; env->GetJavaVM(&vm); - PluginJniHelper::setJavaVM(vm); + cocos2d::PluginJniHelper::setJavaVM(vm); } diff --git a/samples/HelloPluginsLua/frameworks/runtime-src/proj.android/jni/lua/main.cpp b/samples/HelloPluginsLua/frameworks/runtime-src/proj.android/jni/lua/main.cpp index 64dfdc21..a6d47d65 100644 --- a/samples/HelloPluginsLua/frameworks/runtime-src/proj.android/jni/lua/main.cpp +++ b/samples/HelloPluginsLua/frameworks/runtime-src/proj.android/jni/lua/main.cpp @@ -1,42 +1,48 @@ -#include "AppDelegate.h" -#include "cocos2d.h" -#include "platform/android/jni/JniHelper.h" -#include +#include + #include +#include + +#include "platform/android/PluginJniHelper.h" + +#include "AppDelegate.h" #include "ConfigParser.h" -#include "PluginJniHelper.h" #define LOG_TAG "main" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +namespace { +std::unique_ptr appDelegate; +} + +void cocos_android_app_init(JNIEnv* env) { LOGD("cocos_android_app_init"); - AppDelegate *pAppDelegate = new AppDelegate(); + appDelegate.reset(new AppDelegate()); JavaVM* vm; env->GetJavaVM(&vm); PluginJniHelper::setJavaVM(vm); } + extern "C" { - bool Java_org_cocos2dx_HelloPluginsLua_AppActivity_nativeIsLandScape(JNIEnv *env, jobject thisz) - { - if (!ConfigParser::getInstance()->isInit()) - { - ConfigParser::getInstance()->readConfig(); - } - return ConfigParser::getInstance()->isLanscape(); - } - - bool Java_org_cocos2dx_HelloPluginsLua_AppActivity_nativeIsDebug(JNIEnv *env, jobject thisz) - { - #ifdef NDEBUG - return false; - #else - return true; - #endif - } -} + bool Java_org_cocos2dx_HelloPluginsLua_AppActivity_nativeIsLandScape(JNIEnv *env, jobject thisz) + { + if (!ConfigParser::getInstance()->isInit()) + { + ConfigParser::getInstance()->readConfig(); + } + return ConfigParser::getInstance()->isLanscape(); + } + bool Java_org_cocos2dx_HelloPluginsLua_AppActivity_nativeIsDebug(JNIEnv *env, jobject thisz) + { + #ifdef NDEBUG + return false; + #else + return true; + #endif + } +}