一、 开发流程
- 在java类中声明并编写native代码
- native代码编译为so文件
- java中引用so库
二、 native编写
#include <jni.h>
#include <string.h>
extern "C" JNIEXPORT jstring JNICALL
Java_com_example_myapplicationcpp_MainActivity_stringFromJNI(
JNIEnv* env,
jobject /* this */) {
std::string hello = "Hello from C++";
return env->NewStringUTF(hello.c_str());
}
1. 函数命名规则