1. The code suffix for C + + is ". cpp"
2. There are two sets of code in the JNI.h file. One is to support C, and the other is to support JNI.
Jni. H Address:mac? user? Douj? Documents? ANDROID-NDK-R10B? Platforms? Android-8?
The code for C in JNI is:
Jstring (*newstringutf) (jnienv*, const Char*);
C in Call mode:
(*env)->newstringutf (env,"haha from c");
The code for C + + in JNI is:
jstring newstringutf (const char* bytes)
{ return Functions->newstringutf (this, bytes);}
How to call in C + +
jniexport jstring jnicall java_cn_itcast_cpp_demoactivity_helloinc * env, Jobject obj) { return env->newstringutf ("haha from c" );}
3. Modify the Android.mk file
Local_path: = $ (call My-dir) include $ (clear_vars) #针对C + + support, tag C + + file extension name local_cpp_extension: = CPP #打的包模块名称. The Libhello.so library is generated based on this. local_module : = Hello local_src_files: = Hello.cpp #需要编译的相关C, C + + code # Log Support Local_ldlibs + =- Llog include $ (build_shared_library)
4. Advantages of C + +
The function parameter names that are not required can be unnamed parameters.
JNI support for C + + and C differences