mirror of
https://github.com/Gongxh0901/kunpolibrary
synced 2025-12-06 04:39:10 +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
|
||||
Reference in New Issue
Block a user