diff --git a/native/cocos/platform/android/java/libs/libcocosanalytics.jar b/native/cocos/platform/android/java/libs/libcocosanalytics.jar index 29e665f8f5..5ed690948f 100644 Binary files a/native/cocos/platform/android/java/libs/libcocosanalytics.jar and b/native/cocos/platform/android/java/libs/libcocosanalytics.jar differ diff --git a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java index 4385eaf085..c33b89288c 100644 --- a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java +++ b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java @@ -179,7 +179,9 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView { @Override public void run() { Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleOnResume(); - CAAgent.onResume(Cocos2dxGLSurfaceView.this.getContext()); + if (CAAgent.isInited()) { + CAAgent.onResume(Cocos2dxGLSurfaceView.this.getContext()); + } } }); } @@ -190,7 +192,9 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView { @Override public void run() { Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleOnPause(); - CAAgent.onPause(Cocos2dxGLSurfaceView.this.getContext()); + if (CAAgent.isInited()) { + CAAgent.onPause(Cocos2dxGLSurfaceView.this.getContext()); + } } }); this.setRenderMode(RENDERMODE_WHEN_DIRTY); diff --git a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java index 67e15a697d..09c34cc1c0 100644 --- a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java +++ b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java @@ -422,7 +422,6 @@ public class Cocos2dxVideoView extends SurfaceView implements MediaPlayerControl mCurrentState = STATE_PLAYBACK_COMPLETED; mTargetState = STATE_PLAYBACK_COMPLETED; - release(true); if (mOnVideoEventListener != null) { mOnVideoEventListener.onVideoEvent(mViewTag,EVENT_COMPLETED); } diff --git a/native/cocos/scripting/js-bindings/script/jsb_cocosanalytics.js b/native/cocos/scripting/js-bindings/script/jsb_cocosanalytics.js index 7e15691d6b..9673d66db9 100644 --- a/native/cocos/scripting/js-bindings/script/jsb_cocosanalytics.js +++ b/native/cocos/scripting/js-bindings/script/jsb_cocosanalytics.js @@ -36,6 +36,10 @@ if (platform === sys.ANDROID) { } }; + cocosAnalytics.isInited = function() { + return jsb.reflection.callStaticMethod(cls_CAAgent, "isInited", "()Z"); + }; + cocosAnalytics.enableDebug = function(enabled) { jsb.reflection.callStaticMethod(cls_CAAgent, "enableDebug", "(Z)V", @@ -326,6 +330,10 @@ if (platform === sys.ANDROID) { } }; + cocosAnalytics.isInited = function() { + return jsb.reflection.callStaticMethod(cls_CAAgent, "isInited"); + }; + cocosAnalytics.enableDebug = function(enabled) { jsb.reflection.callStaticMethod(cls_CAAgent, "enableDebug:", @@ -594,6 +602,10 @@ if (platform === sys.ANDROID) { console.log("Cocos Analytics module isn't available on this platform!"); }; + cocosAnalytics.isInited = function() { + return false; + }; + cocosAnalytics.enableDebug = function(enabled) { }; diff --git a/native/templates/js-template-binary/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm b/native/templates/js-template-binary/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm index 4d63a42d0e..de05bea003 100755 --- a/native/templates/js-template-binary/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm +++ b/native/templates/js-template-binary/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm @@ -117,7 +117,9 @@ static AppDelegate* s_sharedApplication = nullptr; If your application supports background execution, called instead of applicationWillTerminate: when the user quits. */ cocos2d::Application::getInstance()->applicationDidEnterBackground(); - [CAAgent onPause]; + if (CAAgent.isInited) { + [CAAgent onPause]; + } } - (void)applicationWillEnterForeground:(UIApplication *)application { @@ -129,7 +131,9 @@ static AppDelegate* s_sharedApplication = nullptr; if (glview == currentView) { cocos2d::Application::getInstance()->applicationWillEnterForeground(); } - [CAAgent onResume]; + if (CAAgent.isInited) { + [CAAgent onResume]; + } } - (void)applicationWillTerminate:(UIApplication *)application { diff --git a/native/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm b/native/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm index 4d63a42d0e..de05bea003 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm +++ b/native/templates/js-template-default/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm @@ -117,7 +117,9 @@ static AppDelegate* s_sharedApplication = nullptr; If your application supports background execution, called instead of applicationWillTerminate: when the user quits. */ cocos2d::Application::getInstance()->applicationDidEnterBackground(); - [CAAgent onPause]; + if (CAAgent.isInited) { + [CAAgent onPause]; + } } - (void)applicationWillEnterForeground:(UIApplication *)application { @@ -129,7 +131,9 @@ static AppDelegate* s_sharedApplication = nullptr; if (glview == currentView) { cocos2d::Application::getInstance()->applicationWillEnterForeground(); } - [CAAgent onResume]; + if (CAAgent.isInited) { + [CAAgent onResume]; + } } - (void)applicationWillTerminate:(UIApplication *)application { diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm b/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm index 4d63a42d0e..de05bea003 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm +++ b/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm @@ -117,7 +117,9 @@ static AppDelegate* s_sharedApplication = nullptr; If your application supports background execution, called instead of applicationWillTerminate: when the user quits. */ cocos2d::Application::getInstance()->applicationDidEnterBackground(); - [CAAgent onPause]; + if (CAAgent.isInited) { + [CAAgent onPause]; + } } - (void)applicationWillEnterForeground:(UIApplication *)application { @@ -129,7 +131,9 @@ static AppDelegate* s_sharedApplication = nullptr; if (glview == currentView) { cocos2d::Application::getInstance()->applicationWillEnterForeground(); } - [CAAgent onResume]; + if (CAAgent.isInited) { + [CAAgent onResume]; + } } - (void)applicationWillTerminate:(UIApplication *)application {