背景
我正在Eclipse中为Android开发一个应用程序,现在我遇到了问题,需要您的帮助。所以我必须从JAVA应用程序中调用用C编写的函数。但是在编写代码的过程中,我有一些问题,您可以在下面看到。我正在等待您的答案和想法...
C 代码:
typdef struct blobData_s {
unsigned long length;
unsigned char data[1];
} blobData_t;
unsigned int CheckEnrollmentExist ( unsigned long hdevice, blobData_t* pInputInfo ) {
// Function code goes here
..........................
return some_value;
}
JAVA代码:
在JAVA代码中,我使用int
代替unsigned long
,这样我就可以编写:
class jblobData_c {
public int langth;
*Question 1.*
}
public class ApplicationMainClass extends Activity {
// Some code goes here
......................
public native int JCheckEnrollmentExist( int jhdevive, *Question 2.* );
}
问题1.
- 在JAVA代码中,我可以使用什么代替
unsigned char
? - 在JAVA代码中,我需要写什么来代替
unsigned char data[1];
?
问题2.
- 如何在JAVA代码中使用
class jblobData_c
代替blobData_t* pInputInfo
? - 在JAVA代码中,我需要写什么代替
blobData_t* pInputInfo
?
JNI代码:
JNIEXPORT jint JNICALL Java_com_Test_JCheckEnrollmentExist(JNIEnv* env, jobject obj, jint jhdevice, *Question 2.* ) {
// Call the base function from C code.
return CheckEnrollmentExist( jhdevice, *Question 3.*);
}
问题3.
- 我必须在
CheckEnrollmentExist
函数中写什么,而不是blobData_t* pInputInfo
,以便使此函数正常工作并且给定的参数相同?这是C代码函数。