mirror of
				https://github.com/Gongxh0901/kunpolibrary
				synced 2025-10-30 19:05:44 +00:00 
			
		
		
		
	仓库中添加内置的demo
This commit is contained in:
		
							
								
								
									
										38
									
								
								demo/native/engine/common/Classes/JNIAndroid/JniTools.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								demo/native/engine/common/Classes/JNIAndroid/JniTools.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| // | ||||
| //  JniTools.cpp | ||||
| //  kungpowGame | ||||
| // | ||||
| //  Created by GongXH on 2021/3/26. | ||||
| // | ||||
|  | ||||
| #include "JniTools.h" | ||||
| #include "../SDKHelper.h" | ||||
| #include <jni.h> | ||||
| #include <android/log.h> | ||||
| #include <java/jni/JniHelper.h> | ||||
| #include "application/ApplicationManager.h" | ||||
| using namespace cc; | ||||
|  | ||||
| #define KUNPO_HELPER "com/kunpo/KunpoHelper" | ||||
|  | ||||
| std::string JniTools::getVersionCode() { | ||||
|     return JniHelper::callStaticStringMethod(KUNPO_HELPER,"getVersionCode"); | ||||
| } | ||||
|  | ||||
| int JniTools::getBuildCode() { | ||||
|     return JniHelper::callStaticIntMethod(KUNPO_HELPER,"getBuildCode"); | ||||
| } | ||||
|  | ||||
| #pragma -mark java回调c++ | ||||
| #if (CC_PLATFORM == CC_PLATFORM_ANDROID) | ||||
| extern "C" | ||||
| { | ||||
|     JNIEXPORT void Java_com_kunpo_KunpoHelper_CallJS(JNIEnv* env, jclass thiz, jstring jsjson) | ||||
|     { | ||||
|         std::string json = JniHelper::jstring2string(jsjson); | ||||
|         CC_CURRENT_ENGINE()->getScheduler()->performFunctionInCocosThread([=]() { | ||||
|              KunpoSDK::SDKHelper::getInstance()->callJS(json.c_str()); | ||||
|         }); | ||||
|     } | ||||
| } | ||||
| #endif | ||||
							
								
								
									
										18
									
								
								demo/native/engine/common/Classes/JNIAndroid/JniTools.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								demo/native/engine/common/Classes/JNIAndroid/JniTools.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| // | ||||
| //  JniTools.hpp | ||||
| //  ZumaGame | ||||
| // | ||||
| //  Created by GongXH on 2021/3/26. | ||||
| // | ||||
|  | ||||
| #ifndef JniTools_hpp | ||||
| #define JniTools_hpp | ||||
| #include "cocos.h" | ||||
| class JniTools | ||||
| { | ||||
| public: | ||||
|     //调用Java的方法 | ||||
|     static std::string getVersionCode(); | ||||
|     static int getBuildCode(); | ||||
| }; | ||||
| #endif /* JniTools_hpp */ | ||||
		Reference in New Issue
	
	Block a user