From 97c076337a9e0fb88a296a19e4d854d4c5ce991d Mon Sep 17 00:00:00 2001 From: kaylyun Date: Thu, 30 Oct 2014 10:21:19 +0800 Subject: [PATCH] BUGFIX:SOMETIMES APP DIRECTLY AT THE STARTUP Sometimes app directly at the startup on android platform. --- .../jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 c413cc8a12..b442f9df7d 100644 --- a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp +++ b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp @@ -17,9 +17,11 @@ extern "C" { } JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() { - Application::getInstance()->applicationDidEnterBackground(); - cocos2d::EventCustom backgroundEvent(EVENT_COME_TO_BACKGROUND); - cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&backgroundEvent); + if (Director::getInstance()->getOpenGLView()) { + Application::getInstance()->applicationDidEnterBackground(); + cocos2d::EventCustom backgroundEvent(EVENT_COME_TO_BACKGROUND); + cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&backgroundEvent); + } } JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() {