问题
void ProcedureParams_Initialize(ProcedureParams* pVal);
flag ProcedureParams_IsConstraintValid(const ProcedureParams* val, int* pErrCode);
flag ProcedureParams_XER_Encode(const ProcedureParams* val, ByteStream* pByteStrm, int* pErrCode, flag bCheckConstraints);
flag ProcedureParams_XER_Decode(ProcedureParams* pVal, ByteStream* pByteStrm, int* pErrCode);
flag ProcedureParams_BER_Encode(const ProcedureParams* val, ByteStream* pByteStrm, int* pErrCode, flag bCheckConstraints);
flag ProcedureParams_BER_Decode(ProcedureParams* pVal, ByteStream* pByteStrm, int* pErrCode);
typedef struct {
GeneralEvthParams g_params;
DataParams d_params;
} EvtHandlerParams;
how i can add .h file directly into my .java file. i'm using NDk and .h file inside my jni folder.i want to use the functions of header file . how i can directly use functions in java activity? please help me
回答1:
You cannot invoke the C/C++ functions directly. The C implementations of Java native functions all have a very specific set of parameters:
JNIEXPORT jint JNICALL Java_com_mycompany_MyClassName_myfunc
(JNIEnv * env, jobject obj, jint code) {
...
}
So you will have to create wrapper functions.
A reasonable approach is to define a class including the Java versions of all your native functions (as either static or instance methods), and invoke them via that class.
To generate C headers from the Java (well, not source but the .class files), you can do:
cd bin/classes
javah com.mycompany.MyClassName com.mycompany.AnotherClassName
来源:https://stackoverflow.com/questions/22040660/include-h-file-into-java-file-in-android-using-jni-as-source-folder-of-h-file